<p>The Merkle tree construction's purpose is enabling cheap <em>proving</em> of the existence of transactions. If some node which doesn't have a transaction, but it has the Merkle root, it can be told by another node which does have the transaction about it, together with a path connecting it to the root, and the receiving node can be sure that that transaction was indeed included in the block whose Merkle root it has.</p>
<p>As for how nodes store transactions which they do want... that is unrelated, and very dependent on the kind of software you're talking about.</p>
<ul>
<li><p>Bitcoin full nodes, for the purpose of validation blocks and future transactions don't actually need to keep transactions at all, and for example Bitcoin Core can run in &quot;pruning&quot; mode where this is done. Instead, just a database of all unspent transaction outputs are kept, indexed by the txids of the transactions they were created by. This is sufficient for validation, and much faster than constantly looking up transactions in all history. There exists node software that works differently.</p>
</li>
<li><p>Wallets will generally only keep transactions that are relevant to the user's balance.</p>
</li>
<li><p>Indexing software, such as that powering blockchain explorer websites, or server software queried by lightweight clients, will generally keep all transactions ever, plus a ton of indexes to quickly find any of them.</p>
</li>
</ul>

CC BY-SA 4.0
2022-06-29T03:36:10.950Z
2022-06-29T03:36:10.950Z
Pieter Wuille
<p>I started reading about how bitcoin transactions are processed and I came across the Merkle Tree. I learned that one of its purposes is to prevent nodes from storing the entire bitcoin transaction history. The bitcoin paper also mentions that after a block is buried under enough blocks, the whole merkle tree can be deleted and the merkle root can be kept in that block. However, none of this whole process mentions nodes keeping track of transactions. So how would a node be able to access previous transactions like the initial bitcoin transaction?</p>

<merkle-tree>
How do Bitcoin miners/nodes access previous transactions?
bubblyducks95
# How do Bitcoin miners/nodes access previous transactions?

(Asked by: username_0 on 2022-06-29)

I started reading about how bitcoin transactions are processed and I came across the Merkle Tree. I learned that one of its purposes is to prevent nodes from storing the entire bitcoin transaction history. The bitcoin paper also mentions that after a block is buried under enough blocks, the whole merkle tree can be deleted and the merkle root can be kept in that block. However, none of this whole process mentions nodes keeping track of transactions. So how would a node be able to access previous transactions like the initial bitcoin transaction?

**Tags:** merkle-tree


---

## 1 answers

### Answer by username_1 on 2022-06-29. Score: 1

The Merkle tree construction's purpose is enabling cheap *proving* of the existence of transactions. If some node which doesn't have a transaction, but it has the Merkle root, it can be told by another node which does have the transaction about it, together with a path connecting it to the root, and the receiving node can be sure that that transaction was indeed included in the block whose Merkle root it has.

As for how nodes store transactions which they do want... that is unrelated, and very dependent on the kind of software you're talking about.

* Bitcoin full nodes, for the purpose of validation blocks and future transactions don't actually need to keep transactions at all, and for example Bitcoin Core can run in "pruning" mode where this is done. Instead, just a database of all unspent transaction outputs are kept, indexed by the txids of the transactions they were created by. This is sufficient for validation, and much faster than constantly looking up transactions in all history. There exists node software that works differently.
* Wallets will generally only keep transactions that are relevant to the user's balance.
* Indexing software, such as that powering blockchain explorer websites, or server software queried by lightweight clients, will generally keep all transactions ever, plus a ton of indexes to quickly find any of them.


---

