A coinbase transaction is the first transaction in a Bitcoin block. Miners create this transaction to claim the block reward, which consists of the block subsidy (newly minted bitcoins) and transaction fees from included transactions. Unlike regular transactions, coinbase transactions generate new bitcoins rather than transferring existing ones.
Key Characteristics of a Coinbase Transaction
Coinbase transactions differ from standard transactions in several ways:
- First in Block: Must be the initial transaction in the block.
Single Input: Contains only one blank input with:
- A TXID (transaction ID) set to all zeros.
- A VOUT (output index) set to the maximum value (
0xffffffff). - BIP 34 Compliance: The
ScriptSigmust start with the current block height. - Segwit Support: If the block includes Segwit transactions, the witness field must contain a 32-byte reserved value.
- Flexible Outputs: Can have multiple outputs, but the total value cannot exceed the block reward (subsidy + fees).
Example ScriptSig Structure:
- **BIP 34 Block Height**: `OP_PUSHBYTES_3` (e.g., `03951a06` for block 400,021).
- **Custom Data**: Miners often include tags (e.g., `2f425443432f20` for "/BTCC/") or extra nonces.Coinbase Transaction Requirements
1. Structural Rules
- Input: Exactly one, with a zero TXID and max VOUT.
- Outputs: One or more, totaling ≤ block reward.
- Locktime: Typically zero.
2. Upgrade-Specific Rules
- BIP 34: Block height in
ScriptSig(prevents duplicate TXIDs). BIP 141 (Segwit):
- Witness Reserved Value: 32-byte field in the witness.
- wTXID Commitment: One output must commit to the witness transaction IDs.
Coinbase Maturity: When Can You Spend the Reward?
Outputs from coinbase transactions can only be spent after reaching 100 confirmations. This rule prevents issues during blockchain reorganizations:
- Why 100 Blocks? Ensures the transaction is irreversibly confirmed, minimizing the risk of invalidation due to chain reorgs.
- Example: The coinbase output from block 400,000 was spent in block 400,101.
👉 Learn more about blockchain security
Common Pitfalls and Notes
- Lost Coins: If a miner fails to claim the full block reward (e.g., sending only 6.25 BTC instead of 12.5 BTC), the unclaimed coins are lost forever.
- Custom Data: Miners often embed messages or tags in the
ScriptSig(e.g., "Mined by AntPool").
Frequently Asked Questions (FAQ)
1. Why does the coinbase transaction have a blank input?
The blank input signifies the creation of new bitcoins, as there’s no previous output to reference.
2. What happens if a miner doesn’t include the block height?
Post-BIP 34, blocks without the height in the ScriptSig are rejected by the network.
3. Can coinbase rewards be split among multiple addresses?
Yes. For example, block 829,513 distributed rewards across 17 outputs.
4. How does Segwit affect coinbase transactions?
Segwit requires a witness reserved value and a wTXID commitment in one output.
Key Takeaways
- Coinbase transactions are unique to miners and create new bitcoins.
- Compliance with BIP 34 and BIP 141 is mandatory for valid blocks.
- Rewards become spendable after 100 confirmations.
For further reading, refer to Bitcoin Developer Documentation.