TransWikia.com

What are "leaf versions" in Taproot?

Bitcoin Asked by Bertram Lund on October 24, 2021

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

2 Answers

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?

  • 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? for information on more extensibility features in taproot.

Answered by Pieter Wuille on October 24, 2021

SegWit introduced 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 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]

Answered by Michael Folkson on October 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP