TeachMeBitcoin

Fixing Transaction Malleability

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Fixing Transaction Malleability

Transaction Malleability was a "Bug" in the original Bitcoin protocol that allowed the identification number of a transaction (the txid) to be changed before it was confirmed. SegWit's biggest achievement was solving this problem once and for all.

1. How Malleability Worked

In ECDSA signatures, there are multiple ways to represent the same mathematical proof.

2. The Nightmare Scenario

Imagine you are waiting for a transaction with ID A.

  1. The transaction is malleated in the mempool and confirmed as ID B.

  2. Your software is looking for ID A, so it thinks the payment never happened.

  3. If you had another transaction that depended on ID A, that second transaction is now Invalid because ID A technically does not exist in the blockchain.

3. The SegWit Solution

By moving the signatures into the Witness field and excluding that field from the txid calculation, SegWit made the txid immutable.

4. Enabling the Lightning Network

The Lightning Network works by exchanging "Commitment Transactions" off-chain.

5. Third-Party Malleability vs. Owner Malleability

Issue Legacy SegWit
ID Modification Possible by Anyone Impossible
Layer 2 Support Weak / Dangerous Native / Secure
Integrity Variable Fixed

In the next section, we will discuss The Witness Discount & Block Weight.

☕ 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!