<p>The merkle tree is dynamically recreated to validate it in a block, the order of transactions in the block implicitly describe what the merkle tree should look like when reconstructed. The transactions are stored as part of the block, quite literally the header, a number stating the number of transactions to follow, and then a list of all the transactions follows.</p>

CC BY-SA 4.0
2020-09-26T00:58:54.480Z
But how do you find a particular transaction or a block that has the particular transaction when you wish to verify the transaction as having taken place?
Bittu
CC BY-SA 4.0
2020-09-26T01:35:56.463Z
You either read all blocks and keep an index of the transactions, or you ask a service that does know.
Murch
CC BY-SA 4.0
2020-09-26T00:42:23.890Z
2020-09-26T00:42:23.890Z
Claris
<p>The whitepaper just gives a conceptual overview of Bitcoin, but certainly isn't a full specification. Anyway, beyond the blockchain itself, keeping track of transactions and UTXOs is more of an implementation detail than a protocol concern. Various explorers, nodes, and wallets will differ in their approaches, but generally there are a few different mappings between transactions and blocks for different purposes:</p>
<h2>Blockchain: block to transaction mapping</h2>
<p>First and foremost, the blocks as included in the blockchain include the transactions they confirmed. The complete blockchain is retained in by archival full nodes. As Anonymous already <a href="https://bitcoin.stackexchange.com/a/99210/5406">explained</a>, the merkle tree is only stored implicitly in the blockchain per each block simply listing its full set of transactions in order. Full nodes recreate the complete merkle tree on demand by rehashing the block's transactions during block validation as well as when a Merkle proof is requested from them.</p>
<h2>Specific interests: Transaction to block mapping</h2>
<p>Wallets generally retain copies of the transactions that involve their addresses. These transaction objects should generally keep the block height and the block hash, so that the wallet can deal with chain reorganizations and keep track of confirmation count. I would suspect that some wallet implementations may also keep the Merkle proof around if they e.g. want to be able to proof the existence of funds to other devices.</p>
<p>Bitcoin Core will keep a full transaction index around when configured with the start-up index <code>-tindex=1</code>.</p>
<h2>UTXO set: Output to transaction/block mapping</h2>
<p>Full nodes maintain the ledger of all Bitcoin funds in form of the Unspent Transaction Output (UTXO) set. UTXOs are uniquely identified via their outpoints ([txid:vout]) which means that they inherently reference the corresponding transaction. A UTXO object should generally also include a direct or indirect reference to the block that confirmed the transaction that created the UTXO.</p>
<h2>Explorers</h2>
<p>Explorers generally keep more comprehensive databases of transactions, blocks, addresses, and UTXOs.</p>

CC BY-SA 4.0
2021-06-29T18:18:59.800Z
2021-06-29T18:18:59.800Z
Murch
<p>I'm not sure u r asking as a human want to verify a certain transaction, or as a developer wants to write code to verify a certain transaction given its block no, address,...etc</p>
<p>1-In general, if user A had say &quot;n Btc&quot; as an UTXO which changed to &quot;n' Btc&quot; after transaction X in block B; then u want to validate the spending of the UTXO &quot;n&quot; (by checking Merkle proof/witness) &amp; the creation of UTXO &quot;n'&quot; in block B.</p>
<p>2- Or as a user, without any coding, u may go to one of these sites
<a href="https://m.btc.com/" rel="nofollow noreferrer">https://m.btc.com/</a>
<a href="https://www.blockchain.com" rel="nofollow noreferrer">https://www.blockchain.com</a>
<a href="https://blockchair.com" rel="nofollow noreferrer">https://blockchair.com</a></p>
<p>-either start by the block # ( if there's say more than 1000 TXs in the block it would be hard to check this way)
ex.
These photos show how did I checked that the coinbase UTXO of block 100,000 got spent in block 266,668
<img src="https://i.sstatic.net/f6kJF.jpg" alt="enter image description here" />
<img src="https://i.sstatic.net/Uhut4.jpg" alt="enter image description here" />
<img src="https://i.sstatic.net/N2qZU.jpg" alt="enter image description here" /></p>
<p>-or by the given user address, u get something like this
Then u search for the UTXO value in the given TX (whether it was input or ouput from the arrow direction &amp; the color as u see here)
<img src="https://i.sstatic.net/kYiVS.jpg" alt="enter image description here" /><img src="https://i.sstatic.net/uPvEi.jpg" alt="enter image description here" />
When u click on it, it will get u to the TX created it  with block no &amp; all info; say I clicked on in the above link, I get the transaction details &amp; the block no
<img src="https://i.sstatic.net/XQLJc.jpg" alt="enter image description here" /></p>
<p>(Yes these r probably wallet addresses, but maybe it would be easier to check from since there's a chronological order while inside one block u don't know what's the index/relative order of ur TX; I mean u didn't say it's given)</p>
<p>3-If u r asking as a developer, I guess this Bitcoin core code tells u how things r really stored
<a href="https://github.com/bitcoin/bitcoin/blob/398dd678338971d2189934713c83c184742f293f/src/coins.h#L60-L65" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/398dd678338971d2189934713c83c184742f293f/src/coins.h#L60-L65</a>
I happen to find it &quot;coincidencly&quot; yesterday when checking this
<a href="https://github.com/mit-dci/utreexo/issues/277" rel="nofollow noreferrer">https://github.com/mit-dci/utreexo/issues/277</a></p>
<p>I hope this helps...</p>

CC BY-SA 4.0
2021-06-23T07:11:51.697Z
2021-06-23T07:11:51.697Z
ShAr
<p>According to the Bitcoin white paper, a block contains the fields &quot;Previous Hash&quot;, &quot;Nonce&quot;, and &quot;Root Hash&quot;. The root hash is a merkle tree root node of all the transactions that have been confirmed in that particular block.</p>
<p>I read in the fifth paragraph of the top answer on <a href="https://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root">What is the Merkle root?</a>:</p>
<blockquote>
<p>If we have a transaction that claims to have been from block #234133,
we can get the transactions for that block, verify the Merkle tree,
and know that the transaction is valid.</p>
</blockquote>
<p>Say a block <code>b</code> somewhere in the blockchain holds <code>t</code> transactions. Where and how is the mapping of a particular set of transaction to a particular block stored? Because the blockchain itself only contains the root hash of all transactions to save space. So are there other hidden components that haven't been published in the white paper and are there resources to get a comprehensive idea about them?</p>
<p>Thanks.</p>

CC BY-SA 4.0
2020-09-26T00:46:41.823Z
The whitepaper is nothing like a statement of how the system is designed, it's at best an overview of the concepts. The actual implementation doesn't even strictly follow what is said, and you shouldn't expect a 9 page document to.
Claris
<transactions><merkle-tree><utxo-set><merkleblock>
How/where is the mapping of a transaction to a particular block stored?
Bittu
# How/where is the mapping of a transaction to a particular block stored?

(Asked by: username_0 on 2020-09-26)

According to the Bitcoin white paper, a block contains the fields "Previous Hash", "Nonce", and "Root Hash". The root hash is a merkle tree root node of all the transactions that have been confirmed in that particular block.

I read in the fifth paragraph of the top answer on [What is the Merkle root?](https://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root):

> If we have a transaction that claims to have been from block #234133,
> we can get the transactions for that block, verify the Merkle tree,
> and know that the transaction is valid.

Say a block `b` somewhere in the blockchain holds `t` transactions. Where and how is the mapping of a particular set of transaction to a particular block stored? Because the blockchain itself only contains the root hash of all transactions to save space. So are there other hidden components that haven't been published in the white paper and are there resources to get a comprehensive idea about them?

Thanks.

**Tags:** transactions, merkle-tree, utxo-set, merkleblock

> **Comments:**
> **username_1**: The whitepaper is nothing like a statement of how the system is designed, it's at best an overview of the concepts. The actual implementation doesn't even strictly follow what is said, and you shouldn't expect a 9 page document to.  

---

## 3 answers

### Answer by username_1 on 2020-09-26. Score: 2

The merkle tree is dynamically recreated to validate it in a block, the order of transactions in the block implicitly describe what the merkle tree should look like when reconstructed. The transactions are stored as part of the block, quite literally the header, a number stating the number of transactions to follow, and then a list of all the transactions follows.

> **Comments:**
> **username_0**: But how do you find a particular transaction or a block that has the particular transaction when you wish to verify the transaction as having taken place?  
> **username_2**: You either read all blocks and keep an index of the transactions, or you ask a service that does know.  

---

### Answer by username_2 on 2021-06-29. Score: 0

The whitepaper just gives a conceptual overview of Bitcoin, but certainly isn't a full specification. Anyway, beyond the blockchain itself, keeping track of transactions and UTXOs is more of an implementation detail than a protocol concern. Various explorers, nodes, and wallets will differ in their approaches, but generally there are a few different mappings between transactions and blocks for different purposes:

## Blockchain: block to transaction mapping

First and foremost, the blocks as included in the blockchain include the transactions they confirmed. The complete blockchain is retained in by archival full nodes. As Anonymous already [explained](https://bitcoin.stackexchange.com/a/99210/5406), the merkle tree is only stored implicitly in the blockchain per each block simply listing its full set of transactions in order. Full nodes recreate the complete merkle tree on demand by rehashing the block's transactions during block validation as well as when a Merkle proof is requested from them.

## Specific interests: Transaction to block mapping

Wallets generally retain copies of the transactions that involve their addresses. These transaction objects should generally keep the block height and the block hash, so that the wallet can deal with chain reorganizations and keep track of confirmation count. I would suspect that some wallet implementations may also keep the Merkle proof around if they e.g. want to be able to proof the existence of funds to other devices.

Bitcoin Core will keep a full transaction index around when configured with the start-up index `-tindex=1`.

## UTXO set: Output to transaction/block mapping

Full nodes maintain the ledger of all Bitcoin funds in form of the Unspent Transaction Output (UTXO) set. UTXOs are uniquely identified via their outpoints ([txid:vout]) which means that they inherently reference the corresponding transaction. A UTXO object should generally also include a direct or indirect reference to the block that confirmed the transaction that created the UTXO.

## Explorers

Explorers generally keep more comprehensive databases of transactions, blocks, addresses, and UTXOs.


---

### Answer by username_3 on 2021-06-23. Score: -4

I'm not sure u r asking as a human want to verify a certain transaction, or as a developer wants to write code to verify a certain transaction given its block no, address,...etc

1-In general, if user A had say "n Btc" as an UTXO which changed to "n' Btc" after transaction X in block B; then u want to validate the spending of the UTXO "n" (by checking Merkle proof/witness) & the creation of UTXO "n'" in block B.

2- Or as a user, without any coding, u may go to one of these sites
<https://m.btc.com/>
<https://www.blockchain.com>
<https://blockchair.com>

-either start by the block # ( if there's say more than 1000 TXs in the block it would be hard to check this way)
ex.
These photos show how did I checked that the coinbase UTXO of block 100,000 got spent in block 266,668
![enter image description here](https://i.sstatic.net/f6kJF.jpg)
![enter image description here](https://i.sstatic.net/Uhut4.jpg)
![enter image description here](https://i.sstatic.net/N2qZU.jpg)

-or by the given user address, u get something like this
Then u search for the UTXO value in the given TX (whether it was input or ouput from the arrow direction & the color as u see here)
![enter image description here](https://i.sstatic.net/kYiVS.jpg)![enter image description here](https://i.sstatic.net/uPvEi.jpg)
When u click on it, it will get u to the TX created it with block no & all info; say I clicked on in the above link, I get the transaction details & the block no
![enter image description here](https://i.sstatic.net/XQLJc.jpg)

(Yes these r probably wallet addresses, but maybe it would be easier to check from since there's a chronological order while inside one block u don't know what's the index/relative order of ur TX; I mean u didn't say it's given)

3-If u r asking as a developer, I guess this Bitcoin core code tells u how things r really stored
<https://github.com/bitcoin/bitcoin/blob/398dd678338971d2189934713c83c184742f293f/src/coins.h#L60-L65>
I happen to find it "coincidencly" yesterday when checking this
<https://github.com/mit-dci/utreexo/issues/277>

I hope this helps...


---

