Mining IPC `createNewBlock` fails with `bad-cb-length` on low-height regtest chains #35126

issue plebhash opened this issue on April 20, 2026
  1. plebhash commented at 9:51 PM on April 20, 2026: none

    I’m not sure whether this is expected after #32420, but I’m seeing Mining.createNewBlock over IPC fail on low-height regtest chains before the IPC client can receive a template and construct its own coinbase.

    Observed behavior

    On Bitcoin Core v31.0, when using the Mining IPC interface on regtest at low block heights, Mining.createNewBlock can throw:

    remote exception: std::exception: TestBlockValidity failed: bad-cb-length, Transaction check failed
    

    In my case this happens with a regtest node after mining one initial block through RPC, so the next template height is 2.

    Potential root cause

    (according to my clanker, @Sjors please sanity check?)

    BlockAssembler::CreateNewBlock() builds an internal coinbase with:

    coinbaseTx.vin[0].scriptSig = CScript() << nHeight;
    

    For heights 1 through 16, the BIP34 height is encoded as a one-byte OP_1 through OP_16. That is below the consensus minimum coinbase scriptSig length of 2 bytes, so TestBlockValidity() rejects the internally assembled block with bad-cb-length.

    RPC mining paths appear to avoid this by setting include_dummy_extranonce = true, but that option does not seem to be exposed in the IPC BlockCreateOptions schema.

    Workaround

    Pre-mine 16 regtest blocks before using the IPC Mining interface. Then the next template height is 17, the BIP34 height encoding is no longer one byte, and createNewBlock succeeds.

  2. plebhash referenced this in commit 5ad03ba765 on Apr 20, 2026
  3. plebhash referenced this in commit ccd0b3cf34 on Apr 20, 2026
  4. ViniciusCestarii commented at 10:27 PM on April 20, 2026: contributor

    Sjors added a comment on [#32420](/bitcoin-bitcoin/32420/) that explicitly acknowledges this regression:

    createNewBlock() now fails at heights <= 16 for IPC clients, which #34860 fixes.

    #34860 hasn't been merged yet.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me