txid = 4508d55cf0d93ac43cbbb13a3b63d7a1e146911745f049893fc6b2d84e4e1256
raw block data = 010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1c0390d50700040679a85a04b568f50c0c901b845a1f79000000000000ffffffff029b7c0d4b0000000017a9145d603130872a1b981e2160cd74c52fc1ba8b96ae870000000000000000266a24aa21a9ed000a4c0ed9889ec350f77856bba12735669d5c4564b64703ff7aaee03c873af20120000000000000000000000000000000000000000000000000000000000000000000000000

(this is the coinbase transaction for block 000000000000000000299bafb05053bb4f043b7425848abdd57a6eadbe404393 ) but double_sha256(raw_block_data) != txid I assume this is because in segwit not all the raw data is hashed. what bytes exactly should be removed ? Why don't the blockchain explorers present the data that gives the txid ? related: How to compute SegWit txid? How to calculate txid for segwit transactions?

1 Answer 1


what bytes exactly should be removed

Those corresponding to the Segwit data fields:

  • segwit flag and marker after the version number (bytes 4-5 with zero-based indexing).
  • segwit witness data between final output and lock time

In general you cannot say something like remove bytes 100-166 because the length and number of inputs and outputs is not fixed - so start position varies and must be calculated by parsing the specific inputs and outputs. The number and length of witnesses also varies but the end of witness data (if present) will be 4 bytes before end of transaction data.

See What are the parts of a Bitcoin transaction in segwit format?

  • 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1c0390d50700040679a85a04b568f50c0c901b845a1f79000000000000ffffffff029b7c0d4b0000000017a9145d603130872a1b981e2160cd74c52fc1ba8b96ae870000000000000000266a24aa21a9ed000a4c0ed9889ec350f77856bba12735669d5c4564b64703ff7aaee03c873af200000000 yep, double hash of this hex results in correct txid
    – Meir
    Mar 10 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.