— —
Follow on X
LESSONS

SegWit and Taproot under the hood

SegWit separated signatures from the transaction ID and introduced block weight. Taproot added Schnorr and lets complex spending conditions hide behind a single key.

7 MIN READ
Two panels on what SegWit and Taproot changed.
LEVEL · Advanced
IN THIS LESSON · 8 OF 9
BY THE END YOU WILL BE ABLE TO ANSWER
  • Why did Lightning need SegWit?
  • What is the Taproot key path?
  • How was SegWit deployed as a soft fork?
  • A block is limited to 4,000,000 weight units. Non-witness bytes count 4 each. If a block had no witness data at all, how many bytes could it hold?

Then prove it: a 3-question quiz · a challenge. The lesson marks itself complete at 100%.

After this lesson you can: explain what SegWit and Taproot changed and why fees differ.

SegWit (BIP 141, activated August 2017)

The witness (signatures and unlocking data) was moved out of the part of the transaction that is hashed into the txid. Two consequences:

  1. Malleability fixed. A third party could previously re-encode a signature and change a txid without invalidating the transaction, which broke anything that pre-signed chains of transactions. Lightning needed this fix.
  2. Block weight. The old 1 MB size limit became a 4,000,000 weight unit limit, where non-witness bytes count 4 and witness bytes count 1. Blocks with many SegWit transactions reach 1.8 to 2.5 MB; a block of only witness data could reach 4 MB. Fees are quoted per virtual byte (weight ÷ 4).

Old nodes see SegWit transactions as "anyone can spend" outputs and accept them, which is how it was a soft fork. The activation fight, settled by user-enforced BIP 148, is told in the governance course.

Table of block weight: non-witness bytes count four units, witness bytes count one, limit four million.
Weight units: witness data is discounted, so the old 1 MB limit became up to 4 MB.

Diagram highlighting how the unlocking code is no longer included as part of the TXID in a segwit transaction.
SegWit moves the unlocking data out of the part that is hashed into the TXID.Image: learnmeabitcoin.com

Taproot (BIPs 340, 341, 342, activated November 2021)

  • Schnorr signatures replace ECDSA for Taproot outputs.
  • P2TR outputs pay to a public key that has been tweaked with the root of a Merkle tree of scripts (MAST). To spend, either sign with the tweaked key (the key path, indistinguishable from any single-sig spend) or reveal one script from the tree plus a proof it was committed (the script path). Unused scripts stay hidden forever.
  • Tapscript updates the scripting rules inside Taproot and reserves room for future opcodes.

For a 2-of-3 multisig, the key path can be a MuSig aggregate of all three; the script path holds fallbacks. On-chain, a cooperative spend looks like one key and one 64-byte signature. Lightning channels, vaults and inheritance scripts all benefit.

Two ways to spend a Taproot output: the key path, which looks like any single signature, and the script path, which reveals one script from a hidden tree.
Key path or script path. Unused scripts are never revealed.

Adoption

Nearly all transactions use SegWit; Taproot adoption grew more slowly and got an unexpected push from inscriptions in 2023, which store data in Taproot witnesses.

MINI CHALLENGEWeight units

A block is limited to 4,000,000 weight units. Non-witness bytes count 4 each. If a block had no witness data at all, how many bytes could it hold?

bytes
CHECK YOURSELF
1/3 Why did Lightning need SegWit?
2/3 What is the Taproot key path?
3/3 How was SegWit deployed as a soft fork?
pick an answer for each question

SOURCES

  1. Learn Me A Bitcoin: SegWit
  2. BIP 341: Taproot
Progress is saved in this browser only.