N
N
NQUAREx2022-03-01 11:26:59
Python
NQUAREx, 2022-03-01 11:26:59

How to check BTC transaction in Python?

I have a payment on my wallet in the bot, how can I check whether a transaction has been made using python? Hash how to check? How?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NQUAREx, 2022-03-01
@NQUAREx

import pandas

your_btc_address = '12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX' # Genesis Block
transactions_url = 'https://blockchain.info/rawaddr/' + your_btc_address

df = pandas.read_json(transactions_url)
transactions = df['txs']
print(transactions)

R
rPman, 2022-03-01
@rPman

Install a wallet with api support, for example bitcoin-core (it is not necessary to store the entire blockchain, the -prune option allows you to specify how much to store on disk, a minimum of 512mb in reality will be plus about 5GB utxo) and it is not necessary to make rpc requests
to it, import private keys into it , it is enough to import only the addresses themselves (then they will only be monitored)
at the time of importing the address, the blockchain will be rescanned, this is a long time, you can specify that it does not scan, but then it is necessary that at the time of importing the address there were no transactions on it (otherwise they will not be taken into account on the balance )
if you do not download the blockchain, it will be possible to analyze only transactions to addresses that are in the wallet
if you want to analyze any addresses, then you need to store the entire blockchain and add txindex=1 to the settings (in my mind, without this, analysis will also work in prune mode, but you won’t be able to understand if the specified hash does not exist in the blockchain in principle or because it is too old and information about it is removed from your local copy)
your commands: importaddress gettransaction etc.
ps you can use public electrum servers (consider the explorer someone else's) different servers give different limits on the depth of transaction storage and the number of requests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question