Overview
A Transaction ID (TXID) is a unique identifier assigned to every Bitcoin transaction. It is computed by performing a double SHA-256 hash on the serialized transaction data and is represented as a 64-character hexadecimal string. TXIDs serve as the primary reference for locating and linking transactions throughout the Bitcoin protocol and ecosystem.
How TXIDs Are Computed
Raw Transaction Data
|
SHA-256(data)
|
SHA-256(result)
|
Reverse byte order
|
TXID (64 hex chars)
Example TXID:
a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d
The double SHA-256 operation (sometimes written as SHA256d or HASH256) is the same hashing scheme used throughout Bitcoin, including block headers and Merkle trees.
TXIDs in the Protocol
TXIDs play several critical roles in Bitcoin:
- Input references: Each transaction input specifies the TXID and output index of the UTXO it is spending. This creates the chain of ownership that constitutes Bitcoin's transaction graph.
- Merkle tree leaves: TXIDs are hashed together to form the Merkle root in each block header.
- Block explorers: Users look up transactions on block explorers by TXID.
- Payment confirmation: Merchants and services track TXIDs to monitor payment status.
SegWit and Malleability
Before SegWit, Bitcoin suffered from transaction malleability, where signature data could be modified without invalidating the transaction, causing the TXID to change. SegWit fixed this by excluding witness data from the TXID calculation.
SegWit also introduced the wtxid (witness TXID), which includes witness data in the hash. The wtxid is used in the witness commitment within the coinbase transaction, while the traditional TXID remains the primary identifier for referencing outputs.
Common Misconceptions
- TXIDs are displayed in reverse byte order compared to the raw hash output. This is a historical convention that can cause confusion when working at the protocol level.
- Having a TXID does not mean a transaction is confirmed — unconfirmed transactions in the mempool also have TXIDs, though they can change if the transaction is replaced via RBF.