Does a Bitcoin TXID Include SegWit Witness Data?
No. For SegWit transactions, the TXID is computed from the serialization without witness data. The WTXID is computed from the witness-inclusive serialization.
Why are there two hashes?
Separating witness data lets Bitcoin preserve TXID-based references to transaction outputs while also committing to the witness bytes through the WTXID and the block's witness commitment.
What if a transaction has no witness?
Its WTXID is equal to its TXID. For the witness Merkle tree, the coinbase transaction is a special case: its WTXID leaf is defined as all zero bytes.
Which identifier is used for a UTXO?
A UTXO outpoint uses the TXID and output index. Do not use WTXID in place of TXID when referencing an input's previous output.
Primary references
Bitcoin Developer Reference — Transactions: https://developer.bitcoin.org/reference/transactions.html
BIP141 — Segregated Witness: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
BIP144 — Segregated Witness Peer Services: https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki
