AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 32 Bitcoin

mining: pad coinbase to fix createNewBlock at heights <=16

Public commit record

What the developer wrote

Authored by Sjors Provoost

93/100 · Strong
mining: pad coinbase to fix createNewBlock at heights <=16

Since #32420, createNewBlock has thrown `bad-cb-length` errors when called at
low block heights because `OP_0` padding stopped being added to coinbase
transactions. (#32420 did add an `include_dummy_extranonce` option which could
bypass this, but it was not exposed to IPC clients.) Fix the problem by padding
coinbase transactions with `OP_0` when necessary to produce valid blocks.

Additionally this commit stops adding `OP_0` padding to the template
`script_sig_prefix` field when `include_dummy_extranonce` is true. This is safe
because non-IPC clients don't use this field, and IPC clients could never set
the option to true, and are expected to add their own nonces in any case.

This also improves documentation about the `script_sig_prefix` field and
`getCoinbaseTx` method.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a bug in Bitcoin Core's block-template creation for new blocks at very low chain heights (blocks 1-16). Since a recent earlier change, the software stopped adding a harmless placeholder byte to the coinbase transaction, causing block creation to fail an internal validity check with a 'bad-cb-length' error. The fix re-adds that placeholder byte for low-height blocks, but only inside the node's own template, not in the data handed to external mining clients. Those clients are now documented as needing to supply their own extra byte. It is a correctness/reliability fix for mining interfaces, not a vulnerability that lets an attacker steal funds or break consensus.

Recommended action

Treat as a routine bug-fix commit. Reviewers should verify that the script_sig_prefix field is consistently set before padding and that the updated functional test exercises both sides of the height-16 boundary. No emergency deployment is warranted; the issue only affects low-height scenarios such as regtest or fresh custom chains, not mainnet.

Security signals we found

01

Consensus-rule violation in generated block template (bad-cb-length) at heights <=16

02

Internal TestBlockValidity failure causing createNewBlock to throw

03

IPC mining clients could not set include_dummy_extranonce, leaving no workaround

04

Fix separates padding in the full coinbase from the script_sig_prefix exposed to IPC clients

Risk score

Why this scored 32/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 5/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.