The witness commitment located in one output of the coinbase transaction contains:OP_RETURN commitment_prefix|witness_commitment
Where commitment_prefix=0xaa21a9ed andwitness_commitment=sha256(sha256(witness_merkle_root|witness_reserved_value)).
The witness_merkle_root is the root of a Merkle tree containing all transactions taking into account their witness data. For the coinbase transaction we cannot use the real hash of the transaction, as we would have a recursive dependency. To solve that we use all 0s:
sha256(sha256(E | F))
│
┌──────────────────┴───────────────────┐
│ │
E = sha256(sha256(A | B)) F = sha256(sha256(C | D))
┌───────────────┴───────────────┐ ┌───────────────┴───────────────┐
│ │ │ │
A (CoinbaseTx) B C D
000... txid_2 txid_3 txid_4
Why do we use a tx id set to all 0s instead of just ignoring the coinbase transaction to create the Merkle root?












