TeachMeBitcoin

Fixing Malleability

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Fixing Malleability

The primary motivation for creating the wTXID was to eliminate Third-Party Malleability. This was a bug (or design quirk) in legacy Bitcoin that allowed anyone to change a transaction's ID without changing its validity.

1. What is Malleability?

In the legacy protocol, the ScriptSig (the signatures) was included in the TXID calculation.

2. Why was this bad?

If you sent a transaction (TX A) and then immediately sent another one (TX B) that spent an output of TX A, you had to reference TXID A in your second transaction.

3. How SegWit Fixed It

By moving signatures to the Witness section and excluding that section from the TXID, the TXID became immutable.

4. Enabling Layer 2

This fix was the "Unlock Key" for the Lightning Network. Lightning relies on a series of pre-signed transactions that haven't been mined yet. Without a fixed TXID, these transactions would be fragile and easily broken by miners.

Property Legacy (Malleable) SegWit (Fixed)
Sig in TXID? Yes No
Miner can change ID? Yes No
Reliable Unconfirmed Chains? No Yes

In the final section, we will build a Python wTXID Calculator.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!