How Did SegWit Fix Bitcoin Transaction Malleability?
Short answer
Bitcoin transaction malleability means that a transaction's identifier can change without changing its intended economic effect. Before SegWit, signatures were included in the data hashed to form the transaction ID (txid). Certain modifications to signature encoding or unlocking data could produce a different txid, complicating systems that prepared a second transaction spending the first transaction's output.
Explanation
Segregated Witness (SegWit), activated in 2017, separates witness data from the legacy txid calculation. For a SegWit input, the signature is committed to by the witness transaction ID (wtxid), but is not part of the txid. Consequently, changing witness data cannot change that transaction's txid.
This was a critical improvement for payment-channel protocols that depend on predictable transaction identifiers. It does not mean all imaginable forms of malleability disappear: transactions involving non-SegWit inputs may still be susceptible, and a transaction's inputs or outputs cannot simply be changed without affecting its txid.
The precise claim is that SegWit fixes the major signature-based third-party malleability problem for SegWit spends, rather than making every Bitcoin transaction universally immutable before confirmation.
