Bitcoin: Under the Hood
SegWit and Taproot: Fixing and Refining the Protocol · 1/2

SegWit: solving transaction malleability

Block 1hash: 0x0a3f..prev: genesisBlock 2hash: 0x1a3f..prev: 0x0a3f..Block 3hash: 0x2a3f..prev: 0x1a3f..

Before 2017, a subtle bug in Bitcoin's design allowed transaction malleability: a third party could alter the unique ID of an unconfirmed transaction without changing what it actually did, by tweaking the signature data in ways that didn't invalidate it. This didn't let anyone steal funds, but it broke systems that relied on predicting a transaction's ID before it confirmed, which was a real problem for early Lightning Network designs that needed to reference transactions that hadn't confirmed yet.

Segregated Witness, or SegWit, fixed this by moving signature data, called the 'witness', outside of the data used to calculate a transaction's ID. Since the ID no longer depends on the signature, altering the signature can't change the ID anymore. As a side effect, SegWit also effectively increased block capacity, since witness data is discounted when counting toward the block size limit, and it was activated without a contentious chain split, unlike the block size debate happening around the same time.