Glossary

Coinbase Height Commitment (BIP-34)

BIP-34 requires the block height to be encoded in the coinbase transaction's scriptSig as an anti-replay measure.

Key Takeaways

  • BIP-34 mandates that every coinbase transaction include the block height as the first item in its scriptSig, guaranteeing that each coinbase transaction has a unique transaction ID.
  • This rule was activated at block 227,931 (March 2013) as a soft fork to solve the duplicate coinbase problem that had already caused two pairs of coinbase outputs to be permanently overwritten in the UTXO set.
  • The height is encoded as a script number push in little-endian format inside the coinbase field, and this encoding will remain a 3-byte value on mainnet for approximately the next 150 years.

What Is the Coinbase Height Commitment?

The coinbase height commitment is a consensus rule introduced by BIP-34 that requires miners to embed the current block height as the first data element in the coinbase transaction's scriptSig. This seemingly simple requirement solves a critical problem: without it, two blocks at different heights could produce identical coinbase transactions, leading to duplicate transaction IDs in the UTXO database.

Before BIP-34, the coinbase scriptSig was entirely freeform. Miners could place anything they wanted in this field (Satoshi famously included a newspaper headline in the genesis block). Because the coinbase transaction has no real inputs (it creates new coins from nothing), two miners collecting the same block reward to the same address with the same scriptSig would produce byte-identical transactions with the same transaction ID. This actually happened twice in Bitcoin's early history.

The Duplicate Coinbase Problem (BIP-30)

The motivation for BIP-34 traces back to two pairs of duplicate coinbase transactions that occurred in 2010:

  • Blocks 91,722 and 91,880 shared an identical coinbase transaction (txid starting with e3bf...b468)
  • Blocks 91,812 and 91,842 shared another identical coinbase transaction (txid starting with d5d2...8599)

In both cases, the later block's coinbase overwrote the earlier one in Bitcoin Core's UTXO database. The original 50 BTC outputs from the earlier blocks were permanently destroyed: they could never be spent because the database entry now pointed to the later transaction.

BIP-30 addressed this by banning any block from including a transaction whose ID matched an existing transaction with unspent outputs. While this prevented future overwrites, it required every node to check every transaction ID against the entire UTXO set during block validation: a computationally expensive operation. BIP-34 provided a more elegant long-term fix by making duplicate coinbase transactions structurally impossible.

How It Works

BIP-34 uses a two-part mechanism: a version bump for blocks and a mandatory height encoding in the coinbase scriptSig.

Block Version Upgrade

BIP-34 introduced version 2 blocks. Under the original activation rules, once 750 of the last 1,000 blocks signaled version 2, version 2 blocks without a valid height commitment were rejected. At the 95% threshold (950 of 1,000), version 1 blocks were rejected entirely. These thresholds were later hardcoded to fixed block heights by BIP-90: the 75% trigger at block 224,413 and the 95% enforcement at block 227,931.

Height Encoding Format

The block height is encoded as a Bitcoin Script number push: a length prefix followed by the height value in little-endian byte order. The first byte of the coinbase scriptSig indicates how many bytes follow for the height value.

# Encoding format: [length_byte] [height_bytes_little_endian]

# Example: Block 227,931 (0x037A6B in hex)
# Height in little-endian: 6B 7A 03
# ScriptSig begins with: 03 6B 7A 03
#   03 = "3 bytes follow"
#   6B 7A 03 = 227,931 in little-endian

# Example: Block 800,000 (0x0C3500 in hex)
# Height in little-endian: 00 35 0C
# ScriptSig begins with: 03 00 35 0C
#   03 = "3 bytes follow"
#   00 35 0C = 800,000 in little-endian

On mainnet, the length prefix has been 0x03 (three bytes) since block 65,536 and will remain so until block 16,777,215: approximately 150 more years at the current block interval. After the height push, the remaining bytes in the coinbase field (up to 100 bytes total) are available for miners to include pool identification tags, extra nonce values, or other arbitrary data.

Special Cases for New Chains

Chains that enforce BIP-34 from genesis (such as signet and testnet4) handle heights 1 through 16 differently. These small values are encoded using the single-byte opcodes OP_1 through OP_16 (0x51 to 0x60) rather than the standard length-prefixed format. The coinbase scriptSig must still be at least two bytes in total length.

Interaction with Coinbase Maturity

The coinbase maturity rule requires that coinbase outputs remain unspendable for 100 blocks after they are created. This delay exists because chain reorganizations can orphan blocks, and if a coinbase output had already been spent, the orphaning would invalidate not just the coinbase but every downstream transaction that depended on it.

BIP-34 and coinbase maturity serve complementary roles in protecting the UTXO set. The maturity rule limits the damage from reorganizations by preventing premature spending of newly minted coins. BIP-34 prevents a different class of problem entirely: UTXO database corruption from duplicate transaction IDs. Together, they ensure that each coinbase output has a unique identity and cannot be spent until the network is reasonably confident the block will remain in the longest chain.

Why It Matters

The coinbase height commitment is easy to overlook because it works silently in the background of every block. But it addresses a fundamental integrity requirement of the UTXO model: every transaction output must be uniquely identifiable. Without BIP-34, the Bitcoin network would need to maintain the computationally expensive BIP-30 duplicate check for every transaction in perpetuity.

For miners and mining pools, BIP-34 is a mandatory part of block template construction. Any block submitted without the correct height in the coinbase will be rejected by every validating node on the network. Pool software and the Stratum v2 mining protocol handle this encoding automatically.

For developers building on Bitcoin's base layer or its Layer 2 protocols like Spark, understanding coinbase height commitments matters because they are part of the chain validation rules that every full node enforces. These rules collectively define what constitutes a valid Bitcoin block and by extension what transactions are considered confirmed.

Use Cases

UTXO Set Integrity

The primary use case is ensuring every entry in the UTXO set is uniquely addressable by its transaction ID and output index. This is not just a theoretical concern: the two historical duplicate pairs resulted in the permanent loss of 100 BTC (two 50 BTC coinbase rewards that were overwritten and can never be recovered).

Simplified Block Validation

After BIP-34 activation, nodes can skip the expensive BIP-30 duplicate transaction check for blocks above height 227,931. Since every coinbase is now guaranteed unique by its height prefix, and non-coinbase transactions derive their uniqueness from their inputs (which include unique coinbase outputs), the entire transaction graph maintains unique IDs without per-block UTXO set scans.

Block Height Verification

The coinbase height commitment provides a lightweight way to verify a block's position in the chain. Block explorers and chain analysis tools can extract the height directly from the coinbase scriptSig without needing to traverse the full block header chain.

Soft Fork Activation Precedent

BIP-34 was the first soft fork to use the version-bits-style miner signaling mechanism (through block version numbers). Its activation model: 75% for rule enforcement and 95% for version rejection: became the template for subsequent upgrades like BIP-66 (strict DER signatures) and BIP-65 (OP_CHECKLOCKTIMEVERIFY). This activation history is covered in depth in the soft fork activation history research article.

Risks and Considerations

The BIP-30 Edge Case

Although BIP-34 made future duplicate coinbases impossible, the two historical duplicate pairs (at blocks 91,722/91,880 and 91,812/91,842) remain grandfathered exceptions in the consensus rules. A deep chain reorganization that rolls back past block 91,880 could theoretically expose inconsistencies between nodes that witnessed the reorg and those that did not. While such a reorganization is extraordinarily unlikely (it would require rolling back over 800,000 blocks), this edge case is the subject of ongoing discussion in the Bitcoin development community as part of the Great Consensus Cleanup proposal.

Encoding Assumptions

The BIP-34 specification requires the height to be encoded as a "minimally encoded serialized CScript" push. Some early blocks after activation used non-minimal encodings (such as padding with extra zero bytes) that are technically valid under loose interpretation but violate the minimal encoding rule. Software parsing coinbase heights must handle these edge cases, particularly when validating historical blocks.

Not a Complete Solution for Transaction Uniqueness

BIP-34 only guarantees uniqueness for coinbase transactions. Non-coinbase transactions derive their uniqueness from their inputs, which ultimately trace back to coinbase outputs. If a non-coinbase transaction could somehow reference identical inputs with identical outputs, it would produce a duplicate ID. In practice, this cannot happen because UTXO consumption is enforced: once an output is spent, it cannot be spent again.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.