TeachMeBitcoin

TXID vs. wTXID Calculation

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

TXID vs. wTXID Calculation

The difference between a TXID and a wTXID comes down to exactly which bytes are fed into the hashing algorithm. Bitcoin uses Double SHA256 (hash256) for both.

1. Calculating the TXID

To calculate the TXID of a SegWit transaction, a node must first "strip" the witness data.

2. Calculating the wTXID

To calculate the wTXID, the node uses the full, unstripped serialization.

3. The "Identity Trap"

Because the TXID ignores the witness, two transactions with different signatures but identical inputs and outputs will have the exact same TXID.

4. Why exclude Marker/Flag from TXID?

The Marker (00) and Flag (01) bytes are excluded from the TXID to ensure that SegWit transactions look like valid legacy transactions to old nodes. If those bytes were included, old nodes would see a version mismatch or a corrupted input list.

Field In TXID? In wTXID?
Version Yes Yes
Marker/Flag No Yes
Input TXIDs Yes Yes
Outputs Yes Yes
Witness Data No Yes
Locktime Yes Yes

In the next section, we will look at the Witness Merkle Tree.

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