<p>To add to Michael Folkson's answer, a question one may have is what the differences are between witness versions and leaf versions. Why do we need both?</p>
<ul>
<li>Leaf versions are not revealed until an output is spent, and thus is not known in general to the payer (who is only given an address). For native witness outputs, the witness version is visible from the the BIP173 address.</li>
<li>Leaf versions do not need to be the same for every script branch. This means that if you have an output that can spent either using an old script, or in rare cases using a fancy new script that needs a new version, the fact that you're using this new version in the first place is not revealed to the network unless it actually needs to be used.</li>
<li>Leaf versions are cheaper, as they are only revealed in witness data (which is discounted by a factor 4 per BIP141). Witness versions are revealed in scriptPubKeys (or scriptSigs for P2SH wrapped ones).</li>
<li>The namespace of leaf versions is less restrictive (there are ~40 of them, while only 17 witness versions).</li>
<li>Leaf versions can be used to change script semantics, but are restricted to a Taproot structure. Witness versions can change anything, including the taproot structure.</li>
</ul>
<p>In general, witness versions seem more appropriate for changes to the &quot;structure&quot; of spending conditions (taproot, graftroot, cross-input aggregation, ...), while leaf versions are more for changes to the execution rules of individual scripts.</p>
<p>See <a href="https://bitcoin.stackexchange.com/questions/96951/what-are-the-different-upgradeability-features-in-the-bip-taproot-bip-341-prop/96952#96952">What are the different upgradeability features in the BIP-Taproot (BIP 341) proposal?</a> for information on more extensibility features in taproot.</p>

CC BY-SA 4.0
2020-07-20T20:51:38.173Z
2020-07-20T20:51:38.173Z
Pieter Wuille
<p>SegWit <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#Witness_program" rel="noreferrer">introduced</a> versioned witness programs. When satisfying a script to spend coins you need to provide a redeem script consisting of a version byte and a witness program. The version introduced with SegWit was version 0 (zero).</p>
<p>The <a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki" rel="noreferrer">Taproot proposal</a> uses this SegWit versioning system by introducing spending rules for version 1. The witness program to satisfy a Taproot spend will be version 1.</p>
<p>The Taproot proposal also introduces a new versioning system in addition to SegWit versions called leaf versions. Each leaf of a Taproot tree will have its own leaf version. This is a version for spending rules from that particular leaf. The leaf version introduced with the Taproot proposal is version 0.</p>
<p>So in answer to your question there is just one leaf version with the Taproot proposal and a new SegWit version (to make two SegWit versions in total). The versions are there for future upgrades and as a user you do not need to upgrade anything like you might say upgrade the &quot;version&quot; of your Bitcoin Core software.</p>
<p>Remember that Taproot is still a proposal at this stage (July 2020) and so at the current time SegWit version 1 and leaf versions are not relevant to any transactions you might make on the Bitcoin network.</p>
<p>[darosior edit: There are 41 possible leaf versions (including version zero) for future upgrades as outlined in <a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-7" rel="noreferrer">BIP-Taproot]</a></p>

CC BY-SA 4.0
2020-07-20T11:13:38.330Z
Maybe worth mentioning that there are 41 possible leaf versions: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-7 .
Antoine Poinsot
CC BY-SA 4.0
2020-07-20T11:23:42.113Z
Where do you get 41 from? The BIP refers to 32 leaf versions satisfying those constraints?
Michael Folkson
CC BY-SA 4.0
2020-07-20T11:32:31.200Z
There are 32 even leaf versions between `0xc0` and `0xfe`, to which we add the 9 values `0x66, 0x7e, 0x80, 0x84, 0x96, 0x98, 0xba, 0xbc, 0xbe`.
Antoine Poinsot
CC BY-SA 4.0
2020-07-20T11:42:15.013Z
Sorry I can't read ;)
Michael Folkson
CC BY-SA 4.0
2020-07-20T10:45:51.377Z
2020-07-20T11:49:21.960Z
2020-07-20T11:49:21.960Z
Michael Folkson
<p>What are &quot;leaf versions&quot;, when do you upgrade a version, how many versions are there and how do they differ from segwit versions?</p>

<schnorr-signatures><taproot>
What are "leaf versions" in Taproot?
Bertram Lund
# What are "leaf versions" in Taproot?

(Asked by: username_0 on 2020-07-20)

What are "leaf versions", when do you upgrade a version, how many versions are there and how do they differ from segwit versions?

**Tags:** schnorr-signatures, taproot


---

## 2 answers

### Answer by username_2 on 2020-07-20. Score: 6 | Accepted answer

SegWit [introduced](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#Witness_program) versioned witness programs. When satisfying a script to spend coins you need to provide a redeem script consisting of a version byte and a witness program. The version introduced with SegWit was version 0 (zero).

The [Taproot proposal](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki) uses this SegWit versioning system by introducing spending rules for version 1. The witness program to satisfy a Taproot spend will be version 1.

The Taproot proposal also introduces a new versioning system in addition to SegWit versions called leaf versions. Each leaf of a Taproot tree will have its own leaf version. This is a version for spending rules from that particular leaf. The leaf version introduced with the Taproot proposal is version 0.

So in answer to your question there is just one leaf version with the Taproot proposal and a new SegWit version (to make two SegWit versions in total). The versions are there for future upgrades and as a user you do not need to upgrade anything like you might say upgrade the "version" of your Bitcoin Core software.

Remember that Taproot is still a proposal at this stage (July 2020) and so at the current time SegWit version 1 and leaf versions are not relevant to any transactions you might make on the Bitcoin network.

[darosior edit: There are 41 possible leaf versions (including version zero) for future upgrades as outlined in [BIP-Taproot]](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-7)

> **Comments:**
> **username_3**: Maybe worth mentioning that there are 41 possible leaf versions: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-7 .  
> **username_2**: Where do you get 41 from? The BIP refers to 32 leaf versions satisfying those constraints?  
> **username_3**: There are 32 even leaf versions between `0xc0` and `0xfe`, to which we add the 9 values `0x66, 0x7e, 0x80, 0x84, 0x96, 0x98, 0xba, 0xbc, 0xbe`.  
> **username_2**: Sorry I can't read ;)  

---

### Answer by username_1 on 2020-07-20. Score: 8

To add to username_2 username_2's answer, a question one may have is what the differences are between witness versions and leaf versions. Why do we need both?

* Leaf versions are not revealed until an output is spent, and thus is not known in general to the payer (who is only given an address). For native witness outputs, the witness version is visible from the the BIP173 address.
* Leaf versions do not need to be the same for every script branch. This means that if you have an output that can spent either using an old script, or in rare cases using a fancy new script that needs a new version, the fact that you're using this new version in the first place is not revealed to the network unless it actually needs to be used.
* Leaf versions are cheaper, as they are only revealed in witness data (which is discounted by a factor 4 per BIP141). Witness versions are revealed in scriptPubKeys (or scriptSigs for P2SH wrapped ones).
* The namespace of leaf versions is less restrictive (there are ~40 of them, while only 17 witness versions).
* Leaf versions can be used to change script semantics, but are restricted to a Taproot structure. Witness versions can change anything, including the taproot structure.

In general, witness versions seem more appropriate for changes to the "structure" of spending conditions (taproot, graftroot, cross-input aggregation, ...), while leaf versions are more for changes to the execution rules of individual scripts.

See [What are the different upgradeability features in the BIP-Taproot (BIP 341) proposal?](https://bitcoin.stackexchange.com/questions/96951/what-are-the-different-upgradeability-features-in-the-bip-taproot-bip-341-prop/96952#96952) for information on more extensibility features in taproot.


---

