<p>Sure:</p>

<ul>
<li>A leaf (transaction) can be pruned when all of its outputs have been spent.  </li>
<li>A node can be pruned when both of its children have been pruned.</li>
</ul>

<p>However, Bitcoin Core doesn't implement this kind of pruning. It was built on the assumption that you download and validate all blocks. Because of this, it operates in one of two modes:</p>

<ul>
<li>No pruning (the default)</li>
<li>Don't keep old blocks or old merkle trees at all, and only track unspent outputs and their scriptPubKeys. This mode doesn't allow you to help new nodes synchronize.</li>
</ul>

CC BY-SA 3.0
2015-02-18T04:06:08.360Z
who does this pruning? Is there any data structure which tracks whether particular output has been spent or not? Or do we have to traverse entire block chain to identify the unspent output?
Curious
CC BY-SA 3.0
2015-02-18T04:06:50.457Z
@Curious Nobody, to my knowledge. But, hypothetically, if it were done, it would be done by individual nodes.
Nick ODell
CC BY-SA 3.0
2015-02-18T06:38:52.537Z
Is there any data structure which tracks whether particular output has been spent or not? Or do we have to traverse entire block chain to identify the unspent output?
Curious
CC BY-SA 3.0
2015-02-18T06:42:54.987Z
@Curious Yes. Originally it tracked only the block a particular transaction was in, but it now tracks each output individually, so that the full block data doesn't need to be consulted. However, this is getting out of the scope of your question; you should [ask a new question](http://bitcoin.stackexchange.com/questions/ask) if you want to know more about this.
Nick ODell
CC BY-SA 3.0
2015-02-18T12:33:22.247Z
Bitcoin core doesn't implement this yet. Pruning is likely to be implemented in 0.11 (the next version).
Jannes
CC BY-SA 3.0
2015-02-18T04:05:35.367Z
2015-09-11T01:37:39.933Z
2015-09-11T01:37:39.933Z
Nick ODell
<p>In Merkle tree, leaves are actual transactions and internal nodes are hash of their childrens. In the Bitcoin paper, Satoshi talks about pruning branches in the Merkle tree to save storage space.</p>

<p>Under what conditions can be the branches pruned? I understand that the Merkle root is used in finding POF for the block. Are there any situations where all nodes in the Merkle tree are pruned except the root?</p>

<block><merkle-tree>
Pruning the branches in Merkle Tree
Curious
# Pruning the branches in Merkle Tree

(Asked by: username_0 on 2015-02-18)

In Merkle tree, leaves are actual transactions and internal nodes are hash of their childrens. In the Bitcoin paper, Satoshi talks about pruning branches in the Merkle tree to save storage space.

Under what conditions can be the branches pruned? I understand that the Merkle root is used in finding POF for the block. Are there any situations where all nodes in the Merkle tree are pruned except the root?

**Tags:** block, merkle-tree


---

## 1 answers

### Answer by username_1 on 2015-02-18. Score: 6

Sure:

* A leaf (transaction) can be pruned when all of its outputs have been spent.
* A node can be pruned when both of its children have been pruned.

However, Bitcoin Core doesn't implement this kind of pruning. It was built on the assumption that you download and validate all blocks. Because of this, it operates in one of two modes:

* No pruning (the default)
* Don't keep old blocks or old merkle trees at all, and only track unspent outputs and their scriptPubKeys. This mode doesn't allow you to help new nodes synchronize.

> **Comments:**
> **username_0**: who does this pruning? Is there any data structure which tracks whether particular output has been spent or not? Or do we have to traverse entire block chain to identify the unspent output?  
> **username_1**: @username_0 Nobody, to my knowledge. But, hypothetically, if it were done, it would be done by individual nodes.  
> **username_0**: Is there any data structure which tracks whether particular output has been spent or not? Or do we have to traverse entire block chain to identify the unspent output?  
> **username_1**: @username_0 Yes. Originally it tracked only the block a particular transaction was in, but it now tracks each output individually, so that the full block data doesn't need to be consulted. However, this is getting out of the scope of your question; you should [ask a new question](http://bitcoin.stackexchange.com/questions/ask) if you want to know more about this.  
> **username_2**: Bitcoin core doesn't implement this yet. Pruning is likely to be implemented in 0.11 (the next version).  

---

