While reading bitcoin source I found this short comment:

// Height first in coinbase required for block.version=2

(From https://github.com/bitcoin/bitcoin/blob/master/src/miner.cpp#L338).

Why this is required? Does it prevent some misuse or attack?

I found that this change was introduced in BIP-0034. In relevant pull request it is justified by following points:

Putting the height in the coinbase is desired for at least two reasons:

  1. It guarantees that every subsequent block and transaction hash is unique.
  2. It can be used to better reason about plausible difficulty for not-yet-connected blocks.

But for me this explains nothing: I don't see how adding height guarantees unique block hashes and I don't understand what is "plausible difficulty for not-yet-connected blocks".


In his comment @amaclin pointed to BIP-30 which provides motivation for BIP-34.

I still don't understand what is "to better reason about plausible difficulty for not-yet-connected blocks" but it seems that the sole point of BIP-34 is to prevent intentional creation of duplicate coinbase transactions.

According BIP-30 they can be used in several attacks:

Recently, an attack that exploits the reference implementation's dealing with duplicate transactions was described and demonstrated. It allows reverting fully-confirmed transactions to a single confirmation, making them vulnerable to become unspendable entirely. Another attack is possible that allows forking the block chain for a subset of the network.

This answer by Pieter Wuille explains blockchain forking in more detail.

Contrary to the explanation in BIP-34 pull request, adding block height to coinbase does not guarantee that every subsequent transaction hash is unique. It only makes harder to create transactions with same hash intentionally. There is still possibility that some unrelated transactions will clash.


It doesn't guarantee that block hashes are unique, because that was already guaranteed, because the previous block hash is part of the block header.

It does guarantee that coinbase transactions will be unique.

  • Can you please explain how previous block hash guarantees block hash uniqueness? – max taldykin Oct 2 '14 at 5:38
  • Why do you think that it is not very important that there were duplicate coinbase transactions? It looks like that the sole reason of adding height is to prevent duplicate coinbase transactions. – max taldykin Oct 2 '14 at 5:42
  • BIP-30 prevents duplicate coinbase transactions. Adding block height allows the programs be less complicated while parsing arriving blocks – amaclin Oct 2 '14 at 7:00
  • 1
    It is important for coinbase transactions to be unique because duplicates can't be referred to because they have the same transaction I'd as the first. Therefore they be spent and the 25 bitcoins (currently) are lost. – Jannes Oct 2 '14 at 23:32
  • 1
    @Jannes That's a good point. You've convinced me, and I've removed the part of my post that was wrong. – Nick ODell Oct 20 '14 at 17:01

adding height guarantees unique block hashes with the probability 1 - 1/(2256) which is very close to 1

different coinbase scripts produce different merkle root which produce different block hashes

  • I don't see why this is true. We have 2^542 possible blocks (542 = 640 bits block size - 32 bits for version - 64 zeros in prev block hash) and 2^192 valid block hashes (192 = 256 - 64 zeroes). So there are 2^350 possible duplicates. How you got 1 - 1/(2^256) from this? – max taldykin Oct 2 '14 at 5:29
  • The same is for merkle roots: different coinbase does not guarantee different merkle roots. It guarantees that you can't intentionally create blocks with equal merkle roots. – max taldykin Oct 2 '14 at 5:32
  • There are 2^256 hashes. So the collision probability between previous and next block is 1/2^256 – amaclin Oct 2 '14 at 6:56
  • Why do you consider only previous block? And how adding height increases uniqueness probability? – max taldykin Oct 2 '14 at 7:04
  • it does not increase/decrease probability of collision. do not read between lines – amaclin Oct 2 '14 at 7:08

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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