Why is the wtxid considered malleable since the transaction is unconfirmed? How can a third-party modify it?
2 Answers
All transaction data is committed to the WTXID, unlike in the case of TXID's.
Malleability is found in the unlocking script/data of a transaction. It is malleable, because is not committed to the signature (circular dependency).
Sources of TX Malleability:
- Signature Malleability
- Input Script Malleability
See BIP62
for a great overview of TX malleability sources.
The unlocking script data is found in input scripts (non-witness tx's) and witnesses (witness tx's). For a witness transaction, if the witness is modified in a way that doesn't affect validity, this necessarily changes the resulting WTXID.
The TXID's of witness transactions are not malleable, because the input script is empty and witness data is stripped for its TXID derivation. Transactions are not referenced by WTXID, but by TXID's.
-
1I should mention, even if only TXIDs are committed to block headers (merkle root), WTXIDs are committed to a coinbase output (witness root), so that once confirmed, none of the witness transaction data cannot be modified.– James C.Jan 15, 2019 at 16:03
To add to James' answer, the "segregated" witness can be switched out for an alternative valid witness which changes the wtxid but not the txid. The txid stays the same if you change the witness as the witness is not hashed for the txid but is for wtxid.
Thanks to Gloria Zhao for providing this graphic from BIP144 during a Bitcoin Core PR review club in June 2021.