3

I am exploring a transaction and if would like to know when was the money created, I guess I would end up with a lot of coinable transactions. For a certain transaction I could explore the previous transactions successively until I found the coinbases. But I imagine this would be a very laborious job that could take a lot of resources. Just like blockchains.info trees ( https://blockchain.info/tree/59587897) but expanding the tree till the coinbase transactions

In the other hand I guess nodes when verifying a transaction do something very similar, don’t they? How could I create this list of coinable transactions that original the bitcoins involved in a particular transaction?

2

If you have running bitcoin core, you can use JSON RPC and any programming language you want.

  1. getrawtransaction <txid>
  2. decoderawtransaction <hex>

Second call will return all inputs of transaction. If transaction has previous tx equal to 32 zeroes, it is coinbase transaction. You should recursively cycle through all parent transactions.

API calls list

  • 1
    That will probably take you hours or days to find all coinbases. – Pieter Wuille Jan 25 '17 at 16:09
  • I already was exploring this idea but is slow as @pieter-wuille suggested I am exploring 20 inputs/s. It would take ages. Isn't any faster alternative? – muimota Jan 25 '17 at 19:23
1

Nodes when verifying a transaction do something very similar, don’t they?

That is true, but there is one difference. When full nodes initialize, they go through each and every transaction in the blockchain since the genesis block. As they go through the transaction, they build up a set of all unspent transaction outputs (UTXOs). When a new transaction arrives,the inputs are checked against this UTXO set to ensure they have not been spent in the past. When verified, the inputs are removed and the new outputs are added to the UTXO set. So, the UTXO set does not contain a tree going back to the coinbase transaction, but rather only transaction outputs that have not yet been spent.

How could I create this list of coinable transactions that original the bitcoins involved in a particular transaction?

The coinbase transaction is the first transaction in any block. You could use JSON-RPC getblockhash and getblock to get block data. After that you can fetch the txid of the first transaction of every block. Then, you could use the getrawtransaction and decoderawtransaction calls to decode every coinbase transaction and get the data that you need like the block rewards, addresses that it paid to etc.

-1

Coinbase transaction is the first transaction of a block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.