I'm trying to hash transactions to get the txid. I get the hex values from blockchain.info. I get the correct hash for all transactions except for the coinbase when I hash it twice. Is there something different about how the coinbase transaction is supposed to be hashed?

The block I have tried is: https://blockchain.info/no/block/0000000000000000000870497004514bd3807cdc98b9f3a57038faf5df04144f.

The txid of the coinbase is supposed to be:

But I get:

3 Answers 3


The txid is the hash of transaction without segwit data. The full coinbase transaction contains the segwit data which will result in the hash that you got. However that is not the txid.


The hash you created is the wtxid (hash of Witness ID), not the txid (hash of Transaction ID):

Transaction ID vs. Witness ID

For the difference between txid and wtxid, see Mastering Bitcoin ch. 7 § "Transaction identifiers".


You appear to have a bad copy of the raw transaction.

When I look at the raw transaction for txid in the blockchain (coinbase transaction for block height 486,273, block hash 00000000000000000083cbfd33b63c2ac10e703266c5749bf3ce2fbff88f5791), I get the following:


01000000 01000000 00000000 00000000

00000000 00000000 00000000 00000000

00000000 00ffffff ff310381 6b07244d

696e6564 20627920 416e7450 6f6f6c6b

2f454231 2f414436 2f4e5941 2f332059

c36d7be1 550000df 320000ff ffffff02

38252e4d 00000000 1976a914 66037132

6d3a2e06 4c278b20 107a65da d847e8a9

88ac0000 00000000 0000266a 24aa21a9

edc11e8c dbd8d442 b27bf8f2 73395baa

83b5da4c 9c3d87fb c539dad7 42480437

10000000 00

When I calculate hashlib.sha256(hashlib.sha256(data).digest()).digest() on that data, I get the correct result.

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.