#32468 rpc: generateblock to allow multiple outputs

full analysis

https://github.com/bitcoin/bitcoin/pull/32468 · polespinasa · +265/-56 in 15 files, 7 commits · labels: RPC/REST/ZMQ

Goal

  • Allow generateblock to create coinbase transactions with multiple outputs and custom amounts on regtest
  • Let generateblock automatically mine mempool transactions when no transaction list is provided
  • Eliminates manual raw block construction boilerplate for developers testing multi-recipient coinbases

This PR updates the `generateblock` RPC to accept multiple addresses or descriptors for the coinbase output, optionally specifying explicit amounts in satoshis while dividing any remainder equally. It also falls back to burning the reward in an OP_RETURN output if no outputs are specified. Furthermore, `generateblock` now mines transactions from the mempool if the `transactions` argument is omitted, and only mines an empty block if an empty list is explicitly passed.

Problem: Developers testing protocols that expect multiple recipients in a coinbase transaction (such as mining pools like Ocean or Braidpool) previously had no clean way to generate such blocks via RPC on regtest without manual raw block construction. Additionally, `generateblock` required explicit transaction hexes or IDs and could not automatically assemble a block from the mempool.

Category: RPC / REST / ZMQ (#36 of 52)

P3 · new feature

  • P3 because it makes regtest block generation more flexible for developers testing multi-output coinbases
  • Defaulting to mempool transactions turns generateblock into a more complete test utility

Extending `generateblock` adds flexibility requested by external developers to simulate multi-output coinbases on regtest. As andrewtoth highlighted, allowing an optional transaction list that defaults to the mempool also makes `generateblock` a more complete testing tool.

Membership: Modifies the arguments and behavior of the generateblock RPC in src/rpc/mining.cpp and src/rpc/client.cpp.

Factors: security/stability 0, bug 0, performance 0, user value 2, leverage 1

Category: Mining (#11 of 13)

P3 · new feature

  • P3 because it improves developer block generation tools on test chains without altering mainnet mining
  • Enables testing pool setups like Ocean or Braidpool without manual raw block construction

Improves developer-facing block generation tools on test chains by allowing customized coinbase outputs and mempool-based template mining, but does not alter mainnet block assembly or pool interfaces.

Membership: Touches src/rpc/mining.cpp to modify regtest block construction and coinbase outputs.

Factors: security/stability 0, bug 0, performance 0, user value 1, leverage 1

Reviewability: Ready

  • Ready to review now that requested design changes are implemented and rebased on master

All requested design changes have been implemented, the PR has been rebased on master, and CI is passing.

Author status: active, recently marked ready for review after implementing custom reward splits and rebasing on master

Resolved concerns:

  • Initial implementation added a new `generatetomany` RPC; andrewtoth suggested extending `generateblock` instead to avoid RPC bloat and deprecation cycles.
  • maflcko noted that test-only logic should not live in `src/node/miner.cpp`; the author moved the custom coinbase mutation logic to `src/rpc/mining.cpp`.
  • Handling JSON arrays vs strings in the CLI argument parser was resolved after prerequisite PR #33230 merged.
  • stickies-v and andrewtoth advocated for custom reward amounts rather than only equal splits; author implemented custom reward pairs in collaboration with bicaru20.

Agreement: Strong

  • Strong consensus to extend generateblock rather than introducing a new RPC method
  • Suggested extending generateblock and adding optional mempool mining (andrewtoth)
  • Guided keeping test-only coinbase mutation logic out of core node miner code (maflcko)
  • Advocated supporting custom reward splits rather than only equal shares (stickies-v)

Strong consensus to extend generateblock; feedback from andrewtoth, maflcko, and stickies-v addressed

Reviewers agreed on the concept and shaped the design: extending generateblock rather than adding a separate RPC, moving the code out of src/node, and supporting explicit per-output reward allocations.

  • andrewtoth proposed extending generateblock to take multiple outputs and optional mempool mining rather than adding generatetomany
  • maflcko guided the implementation to avoid modifying core miner code in src/node
  • stickies-v argued for implementing custom rewards as the general solution, which the author incorporated

Review verdicts (DrahtBot): 0

Dependencies

Enables:

  • Simplifies regtest functional tests by removing boilerplate raw block construction for custom coinbases

Files

153 lines under test/bench/ci.

  • src/rpc/mining.cpp +125/-37
  • test/functional/rpc_generate.py +118/-3
  • test/functional/p2p_outbound_eviction.py +5/-5
  • doc/release-notes-32468.md +5/-0
  • test/functional/feature_block.py +2/-2
  • test/functional/feature_assumeutxo.py +1/-1
  • test/functional/feature_fastprune.py +1/-1
  • test/functional/mempool_sigoplimit.py +1/-1
  • test/functional/mempool_truc.py +1/-1
  • test/functional/mempool_updatefromblock.py +1/-1
  • test/functional/rpc_blockchain.py +1/-1
  • test/functional/rpc_getblockstats.py +1/-1
  • test/functional/rpc_txoutproof.py +1/-1
  • test/functional/wallet_bumpfee.py +1/-1
  • src/rpc/client.cpp +1/-0

Card

This PR modifies the generateblock RPC to allow multiple coinbase outputs with custom reward amounts, falls back to burning reward in OP_RETURN if no outputs are given, and mines the mempool if the transactions argument is omitted. It addresses a gap where regtest testing could not simulate multi-output coinbase distributions used by modern mining pool setups like Ocean or Braidpool. Reviewers andrewtoth and stickies-v guided the architecture toward extending generateblock with custom amounts rather than introducing new commands. The PR was recently updated with custom reward allocation logic, rebased on master, and is ready for review.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:49, confidence high, input hash 392af45e9f8b3624