Pages:
Author

Topic: Calculate how many BTC an address own from RPC calls - page 2. (Read 396 times)

full member
Activity: 615
Merit: 154
CEO of Metaisland.gg and W.O.K Corp
Thanks for these answers, it helps to give me new idea to dig!

 Grin Grin Grin
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
getblockhash thehash
then for each nTx I get the txhash
getrawtransaction txhash
which give me the vin and the value of all the transactions.

getrawtransaction will only find mempool transactions, and only if you pass -txindex=1, so your setup already can't handle confirmed transactions.  But it does support fetching them from a particular block if you know it's block hash, which you have just got from getblockhash (alternatively you can retrieve them from Blockchair).

getrawtransaction txhash true blockhash

Will also give you the vouts, and their values under the vout array --> but also, more importantly, their addresses in the vout array --> scriptPubKey --> addresses. With this method the address contained in vin is not directly available but you can retrieve it from the vouts of the connected transaction listed in vin --> txid.

The second argument is verbose=true it tells bitcoin core to return the result as JSON instead of a string. It even gives you the transaction hex in case you want to run decoderawtransaction on it.

Note that all this only works for transactions contained in the block identified by the block that you passed.
legendary
Activity: 4466
Merit: 3391
If you want to know the amount of btc currently at an address, you would sum all the UTXOs associated with that address (using "scantxoutset"?).
full member
Activity: 615
Merit: 154
CEO of Metaisland.gg and W.O.K Corp
I am trying to figure out how https://www.blockchain.com/ calculates the source and destinations of a transaction with the goal to know how much BTC every address owns.
I have no problem to get the VOUT

getblockhash thehash
then for each nTx I get the txhash
getrawtransaction txhash
which give me the vin and the value of all the transactions.

The problem is that I do not have the information as from which address the transactions are coming from.
I know the value and the destination, but not the source.

In consequence, I can only do the sum of all BTC that were sent to that address, but I cannot subtract the spent BTC.

However in https://www.blockchain.com/ they seems to have the source and destination, but for the source, I ignore how they are doing it from the txhash.

Anyone could suggest somewhere to look to solve my problem?
Pages:
Jump to: