<p>If you have running bitcoin core, you can use <a href="https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)" rel="nofollow noreferrer">JSON RPC</a> and any programming language you want.</p>

<ol>
<li>getrawtransaction &lt;txid&gt;</li>
<li>decoderawtransaction &lt;hex&gt;</li>
</ol>

<p>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.</p>

<p><a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow noreferrer">API calls list</a></p>

CC BY-SA 3.0
2017-01-25T16:09:34.187Z
That will probably take you hours or days to find all coinbases.
Pieter Wuille
CC BY-SA 3.0
2017-01-25T19:23:13.977Z
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
CC BY-SA 3.0
2017-01-25T14:52:23.267Z
2017-01-25T14:52:23.267Z
Zergatul
<blockquote>
  <p>Nodes when verifying a transaction do something very similar, don’t they? </p>
</blockquote>

<p>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.</p>

<blockquote>
  <p>How could I create this list of coinable transactions that original the bitcoins involved in a particular transaction?</p>
</blockquote>

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

CC BY-SA 4.0
2019-05-09T15:36:44.317Z
2019-05-09T15:36:44.317Z
Ugam Kamat
<p>Coinbase transaction is the first transaction of a block.</p>

CC BY-SA 4.0
2019-05-09T13:15:09.497Z
2019-05-09T13:15:09.497Z
Vizeet Srivastava
<p>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 ( <a href="https://blockchain.info/tree/59587897" rel="nofollow noreferrer">https://blockchain.info/tree/59587897</a>) but expanding the tree till the coinbase transactions </p>

<p>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?</p>

<transactions><transaction-verification><coinbase-transaction>
How can I find the coinbase transactions where the bitcoins involved in a transaction were created?
muimota
# How can I find the coinbase transactions where the bitcoins involved in a transaction were created?

(Asked by: username_0 on 2017-01-24)

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?

**Tags:** transactions, transaction-verification, coinbase-transaction


---

## 3 answers

### Answer by username_1 on 2017-01-25. Score: 2

If you have running bitcoin core, you can use [JSON RPC](https://en.bitcoin.it/wiki/API_reference_(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](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list)

> **Comments:**
> **username_2**: That will probably take you hours or days to find all coinbases.  
> **username_0**: I already was exploring this idea but is slow as @username_2-username_2 suggested I am exploring 20 inputs/s. It would take ages. Isn't any faster alternative?  

---

### Answer by username_3 on 2019-05-09. Score: 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.


---

### Answer by username_4 on 2019-05-09. Score: -1

Coinbase transaction is the first transaction of a block.


---

