<p>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.</p>

CC BY-SA 3.0
2018-04-15T19:17:54.050Z
Thanks, would you mind telling me what segwit data is?
jørgen k. s.
CC BY-SA 3.0
2018-04-15T19:21:42.723Z
See BIP 144: https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki. The hash that you have is the witness ID.
Ava Chow
CC BY-SA 3.0
2018-04-15T19:10:26.793Z
2018-04-15T19:10:26.793Z
Ava Chow
<p>The hash you created is the <code>wtxid</code> (hash of Witness ID), not the <code>txid</code> (hash of Transaction ID):</p>

<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki#hashes" rel="nofollow noreferrer"><img src="https://i.sstatic.net/j7PRJ.png" alt="Transaction ID vs. Witness ID"></a></p>

<p>For the difference between  <code>txid</code> and <code>wtxid</code>, see <a href="https://github.com/bitcoinbook/bitcoinbook/blob/362f0b340f6b10b4dcac82a06062ca92528fe7df/ch07.asciidoc#transaction-identifiers" rel="nofollow noreferrer"><em>Mastering Bitcoin</em> ch. 7 § "Transaction identifiers"</a>.</p>

CC BY-SA 4.0
2018-10-27T23:20:35.230Z
2018-10-27T23:20:35.230Z
Geremia
<p>You appear to have a bad copy of the raw transaction.</p>

<p>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:</p>

<p>Code:</p>

<pre><code>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
</code></pre>

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

CC BY-SA 4.0
2018-04-16T11:04:03.937Z
2018-05-12T23:40:43.330Z
2018-05-12T23:40:43.330Z
Kleyn Bank
<p>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?</p>

<p>The block I have tried is: <a href="https://blockchain.info/no/block/0000000000000000000870497004514bd3807cdc98b9f3a57038faf5df04144f" rel="nofollow noreferrer">https://blockchain.info/no/block/0000000000000000000870497004514bd3807cdc98b9f3a57038faf5df04144f</a>.</p>

<p><br/>
The txid of the coinbase is supposed to be:  <br/>
44763fed906f1a0e8b82e7497ac83856baa4b1c5621affdce04108a212018c4e</p>

<p>But I get:  <br/>
6e129e567970540b2812ec58388d131c3b8fdbf4e4c992d140e255895df2992e</p>

<hash><coinbase-transaction><transaction-id>
Getting the wrong txid for coinbase transactions
jørgen k. s.
# Getting the wrong txid for coinbase transactions

(Asked by: username_0 on 2018-04-15)

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:   
44763fed906f1a0e8b82e7497ac83856baa4b1c5621affdce04108a212018c4e

But I get:   
6e129e567970540b2812ec58388d131c3b8fdbf4e4c992d140e255895df2992e

**Tags:** hash, coinbase-transaction, transaction-id


---

## 3 answers

### Answer by username_1 on 2018-04-15. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: Thanks, would you mind telling me what segwit data is?  
> **username_1**: See BIP 144: https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki. The hash that you have is the witness ID.  

---

### Answer by username_2 on 2018-10-27. Score: 2

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

[![Transaction ID vs. Witness ID](https://i.sstatic.net/j7PRJ.png)](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki#hashes)

For the difference between `txid` and `wtxid`, see [*Mastering Bitcoin* ch. 7 § "Transaction identifiers"](https://github.com/bitcoinbook/bitcoinbook/blob/362f0b340f6b10b4dcac82a06062ca92528fe7df/ch07.asciidoc#transaction-identifiers).


---

### Answer by username_3 on 2018-04-16. Score: 0

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:
Code:
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.


---

