Generatetomany
First approach was to create a generatetomany
rpc call. That approach can be seen here https://github.com/polespinasa/bitcoin/pull/3
Generateblock
Modifies generateblock
to allow a user to set multiple outputs in the coinbase transaction. If an empty set is provided, the block will be empty. If no set of transactions is provided, the block will mine the mempool. If a set of transactions is provided only that set of txs will be mined.
0$ ./bitcoin-cli -rpcport=18443 generateblock '["bcrt1qal6p633hvwz2yp5mav0qy7u2az8gkn2xywnj6v", "bcrt1qvr3qgyhw6y0e0zj97v0j5yc40xtpea4wqj0g43"]' []
1{
2 "hash": "74deaa8b6f677321a76c6508d57c47896da440db411663a89879c091ca08cbc4"
3}
4$ ./bitcoin-cli -rpcport=18443 generateblock '["bcrt1qal6p633hvwz2yp5mav0qy7u2az8gkn2xywnj6v", "bcrt1qvr3qgyhw6y0e0zj97v0j5yc40xtpea4wqj0g43"]'
5{
6 "hash": "55171d2db37a50cddb507d186da324e20227384cf0a201c38abb0bad65bf5d98"
7}
Motivation
https://x.com/SuperTestnet/status/1921220086645342550
Citating @supertestnet
When mining a block on regtest, the command “generatetoaddress” is available if you want to send the entire coinbase to 1 address. Let’s add generatetomany in case you want to split up the coinbase among multiple addresses, similar to how the “sendtoaddress” and “sendmany” commands both exist and let you send money to (1) one address or (2) multiple addresses. The generatetomany command would be particularly useful for simulating protocols that send money to multiple recipients directly from a coinbase, as several pools do now, like ocean and braidpool.
Notes
- Needs release note
- Changes on
generateblock
are not backwards compatible as now it takes an array of outputs instead a single output. This should not be critical as it is a test RPC.