<p>The script of the input to a coinbase transaction can hold up to 100 bytes of arbitrary data. After <a href="https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki" rel="nofollow noreferrer">BIP 34</a>, the block height must be the first thing in that script. Since each block has a different height, this rule ensures that each coinbase transaction is unique as the block heights will always be different.</p>

<p>Furthermore, since miners can put whatever arbitrary data they want in that input script, they frequently use that as an extra nonce. Instead of reselecting transactions when all of the nonces are exhausted, miners will increment a value known as the extranonce which is put in the input script.</p>

<hr>

<p>Also, before BIP 34 activated, there were in fact cases of identical coinbase transactions in different blocks. Only the outputs from the most recent of these identical coinbase transactions are spendable. Spending outputs from these transactions does not spend all of the outputs, only the ones from the most recent one. This means that the outputs from the earlier coinbases are unspendable and those coins are provably lost forever.</p>

CC BY-SA 4.0
2018-08-21T20:11:36.230Z
I see, that makes sense. Just to clarify one thing, block heights are only guaranteed to be different for a coinbase transactions for the _same_ miner because coinbase transactions for different miners could potentially have the same block height in the case of a temporary fork?
connorwstein
CC BY-SA 4.0
2018-08-21T21:50:24.037Z
Yes, block heights are only different for the same miner.
Ava Chow
CC BY-SA 4.0
2018-08-21T19:48:30.083Z
2018-08-21T19:48:30.083Z
Ava Chow
<p>Based on the format of a coinbase transaction described here: <a href="https://bitcoin.stackexchange.com/questions/20721/what-is-the-format-of-the-coinbase-transaction">What is the format of the coinbase transaction?</a>, I don't see how the all the coinbase transactions for a given miner do not all have the same hash assuming the miner was just using a single pubkey and the block rewards were the same. If they all have the same hash then when you spend one of them, you effectively use them all because that transaction hash has now been used as an input. Clearly that wouldn't make sense, so how are they ensured to be unique transaction hashes? </p>

CC BY-SA 4.0
2018-08-21T23:26:27.263Z
Closely related, almost duplicate: https://bitcoin.stackexchange.com/questions/30764/why-block-height-is-required-in-coinbase/30780#30780
Nate Eldredge
<coinbase-transaction>
How does the hash of a coinbase transaction differ for the same miner?
connorwstein
# How does the hash of a coinbase transaction differ for the same miner?

(Asked by: username_0 on 2018-08-21)

Based on the format of a coinbase transaction described here: [What is the format of the coinbase transaction?](https://bitcoin.stackexchange.com/questions/20721/what-is-the-format-of-the-coinbase-transaction), I don't see how the all the coinbase transactions for a given miner do not all have the same hash assuming the miner was just using a single pubkey and the block rewards were the same. If they all have the same hash then when you spend one of them, you effectively use them all because that transaction hash has now been used as an input. Clearly that wouldn't make sense, so how are they ensured to be unique transaction hashes?

**Tags:** coinbase-transaction

> **Comments:**
> **username_1**: Closely related, almost duplicate: https://bitcoin.stackexchange.com/questions/30764/why-block-height-is-required-in-coinbase/30780#30780  

---

## 1 answers

### Answer by username_2 on 2018-08-21. Score: 3 | Accepted answer

The script of the input to a coinbase transaction can hold up to 100 bytes of arbitrary data. After [BIP 34](https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki), the block height must be the first thing in that script. Since each block has a different height, this rule ensures that each coinbase transaction is unique as the block heights will always be different.

Furthermore, since miners can put whatever arbitrary data they want in that input script, they frequently use that as an extra nonce. Instead of reselecting transactions when all of the nonces are exhausted, miners will increment a value known as the extranonce which is put in the input script.

---

Also, before BIP 34 activated, there were in fact cases of identical coinbase transactions in different blocks. Only the outputs from the most recent of these identical coinbase transactions are spendable. Spending outputs from these transactions does not spend all of the outputs, only the ones from the most recent one. This means that the outputs from the earlier coinbases are unspendable and those coins are provably lost forever.

> **Comments:**
> **username_0**: I see, that makes sense. Just to clarify one thing, block heights are only guaranteed to be different for a coinbase transactions for the _same_ miner because coinbase transactions for different miners could potentially have the same block height in the case of a temporary fork?  
> **username_2**: Yes, block heights are only different for the same miner.  

---

