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.
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.
DrahtBot
commented at 5:34 PM on May 10, 2025:
contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
#36710 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36710.svg"></sub> (test: Replace hardcoded extended keys with ExtendedKey helpers by nebula-21)
#36598 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36598.svg"></sub> ([Demo] validation: remove AssumeUTXO by l0rinc)
#36451 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36451.svg"></sub> (refactor: Use NotNull for CreateNewBlock and pimpls by maflcko)
#35793 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35793.svg"></sub> (Implement BIP 54 (Consensus Cleanup) without mainnet activation by darosior)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
DrahtBot added the label RPC/REST/ZMQ on May 10, 2025
polespinasa force-pushed on May 10, 2025
polespinasa
commented at 5:42 PM on May 10, 2025:
member
I would like to discuss how to implement reward distribution. Do we ask the user for the exact number of bitcoins for each address or do we opt to use percentages of the reward?
IMHO it is better to use percentages, it makes things easier for the user.
DrahtBot added the label CI failed on May 10, 2025
DrahtBot
commented at 5:48 PM on May 10, 2025:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task tidy: https://github.com/bitcoin/bitcoin/runs/41993075774</sub>
<sub>LLM reason (✨ experimental): The CI failure is due to a build error related to missing members in node::BlockAssembler::Options.
</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
polespinasa force-pushed on May 10, 2025
andrewtoth
commented at 5:56 PM on May 10, 2025:
contributor
The generateblock command takes either an address or descriptor as its first argument. Perhaps it would be easier to extend that RPC to also take an array of address or descriptor and value pairs? That way we won't need a new RPC.
polespinasa
commented at 5:59 PM on May 10, 2025:
member
Perhaps it would be easier to extend that RPC to also take an array of address or descriptor and value pairs?
That would be easy as the code is already done on the new RPC. But this change would not be backwards compatible, idk if we want to keep it that way.
There are some softwares like Polar that would be affected by this.
polespinasa force-pushed on May 10, 2025
andrewtoth
commented at 6:17 PM on May 10, 2025:
contributor
But this change would not be backwards compatible
Sure it would be. Just parse an array first and if that fails parse a string.
DrahtBot removed the label CI failed on May 10, 2025
polespinasa
commented at 9:48 PM on May 10, 2025:
member
Just parse an array first and if that fails parse a string.
Oh right, that's an option. I will let it as it is for now to see other contributors' opinions.
May take your approach later.
supertestnet
commented at 11:38 PM on May 10, 2025:
none
Can a PSBT be constructed with only outputs, no inputs? If so, then maybe generateblock could accept a psbt or a string as an argument. If it is a psbt, it must contain outputs but no inputs.
But also, due to fees being variable, it may be useful to have some kind of "remainder" option so that you can say, for example, "give 1 btc apiece to the first 3 addresses, and give the remainder to the last address"
polespinasa
commented at 7:51 AM on May 11, 2025:
member
Can a PSBT be constructed with only outputs, no inputs?
I'm not sure using a PSBT is the best approach. If we check the normal workflow for a PSBT we see it is intended to:
Create the PSBT with inputs and outputs but no metadata
Updated with the data needed to spend the UTXOs in the inputs
Signed
Finalized
IMO using PSBTs here does not make sense, we don't need any of that, we don't need to share with other users or software to sign or add information to inputs. It's easier to just provide a JSON with the addresses and amounts (it's the only info we need), also using a JSON it's easier to implement with less changes.
But also, due to fees being variable, it may be useful to have some kind of "remainder" option so that you can say, for example, "give 1 btc apiece to the first 3 addresses, and give the remainder to the last address"
Do you have any idea on how that could look like?
Maybe something like this; where amount_fixed takes a number and share_reminder is a boolean:
generatetomany 1 [{addr1, amount_fixed, share_remainder}, ...]
bitcoin-cli generatetomany "{\"bcrt1qal6p633hvwz2yp5mav0qy7u2az8gkn2xywnj6v\":1,\"bcrt1q3me8uxjzw2egq76hjw6zcgzmlhlzzztfwqzjfv\":1,\"bcrt1q57yu04dn4l0zxv6ul4prm7favr630d3lmwvjh0\":1,\"bcrt1qal6p633hvwz2yp5mav0qy7u2az8gkn2xywnj6v\":\"remainder\"}" <-- note the remainder in the last btc address
polespinasa
commented at 8:08 AM on May 11, 2025:
member
note the remainder in the last btc address
what if you want to split the reminder between multiple addresses?
a1denvalu3
commented at 11:09 AM on May 11, 2025:
none
note the remainder in the last btc address
what if you want to split the reminder between multiple addresses?
Generally, I am not sure about modifying real code to accommodate test-only code. It would be better to not modify src/node at all and just put the test-only code in the test-only code paths.
(Unless the code may be useful outside of tests, but then you'll have to explain how)
Will delete it, was just added as all the else statement code is not needed for the simeple generatetoaddress.
Generally, I am not sure about modifying real code to accommodate test-only code. It would be better to not modify src/node at all and just put the test-only code in the test-only code paths.
I'm not understanding this part, what do you mean by test-only code? I don't see a way to add this functionality without modifying this src/node/... files. Care to explain more?
Also maybe we would want to follow @andrewtoth advice and not create a new rpc command in the first place.
polespinasa
commented at 5:30 PM on May 11, 2025:
member
All fields with "remainder" to have the remainder split equally amongst them?
I don't see duplicating entries as a good option. Could lead to errors. I think is better to have two camps for each address entry, one for the amount (can be 0) and one for reminder (can be done with 0 or 1 or by setting "remainder" or an empty string)
polespinasa
commented at 5:31 PM on May 11, 2025:
member
Also maybe we would want to follow @andrewtoth advice and not create a new rpc command in the first place.
Still not sure about this, would like to know more opinions, for other things like send we have multiple RPCs. Anyway, it's an easy change, so it's something we can do at the end if we want.
a1denvalu3
commented at 5:51 PM on May 11, 2025:
none
duplicating entries
How is it duplicating entries? In the example there is a different address for each entry.
polespinasa
commented at 5:54 PM on May 11, 2025:
member
How is it duplicating entries?
First address is duplicated. Anyway it is duplicated in case you want to assign an amount to an address + remainder.
polespinasa force-pushed on May 12, 2025
polespinasa force-pushed on May 12, 2025
polespinasa force-pushed on May 12, 2025
DrahtBot added the label CI failed on May 12, 2025
This is necessary to avoid RegenerateCommitments to return -1 so breaking the code.
Idk if there's a better approach to it.
polespinasa renamed this: rpc:generatetomany rpc: generatetomany on May 12, 2025
DrahtBot removed the label CI failed on May 12, 2025
mzumsande
commented at 2:45 PM on May 12, 2025:
contributor
Could the motivation be added here? Doesn't seem ok having to resort to twitter (where people without an account can't even see most of the thread) to know the reason for a PR.
supertestnet
commented at 4:24 PM on May 12, 2025:
none
Here is my motivation:
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.
andrewtoth
commented at 4:39 PM on May 12, 2025:
contributor
Still not sure about this, would like to know more opinions, for other things like send we have multiple RPCs
Since I don't seem to have convinced you, here are some more arguments for why this feature belongs in generateblock instead of a new RPC:
New RPCs require adding more code to test, and once added must go through a deprecation cycle to be removed (if they can be removed at all without disrupting too many users).
Consumers of the RPCs must write additional code for the new RPC, instead of simply modifying the argument type.
generateblock is much more flexible than generatetoaddress (or generatetodescriptor), since it takes the txs to include as the second argument. For advanced test cases, it is likely that users would want this functionality to test multiple output coinbases with blocks that mine non-standard txs or otherwise don't mine the entire mempool. They would not have this capability with generatetomany as implemented here, but would have that for free with generateblock.
generateblock currently doesn't collect transaction fees (https://github.com/bitcoin/bitcoin/issues/31684), so adding this functionality to it would fix this issue. Users could just call generateblock with an array containing a single address/descriptor:value pair that has the reward plus fees.
generateblock is capable of mining invalid blocks, since the txs to mine in the second argument can be any set of txs. We can similarly punt the calculation of the coinbase reward to the caller, so they must correctly calculate that all the values of the outputs add up to no more than the correct reward + fees. This removes the bikeshedding of whether to use remainder or split values up evenly.
polespinasa
commented at 6:55 PM on May 12, 2025:
member
generateblock is much more flexible than generatetoaddress (or generatetodescriptor), since it takes the txs to include as the second argument. For advanced test cases, it is likely that users would want this functionality to test multiple output coinbases with blocks that mine non-standard txs or otherwise don't mine the entire mempool. They would not have this capability with generatetomany as implemented here, but would have that for free with generateblock.
This is a fair point, the only bad thing is that (if I'm not wrong) generateblock is thought to be used always with a given set of txs and that may not always be the use case. Maybe would be worth to implement it on both RPC?
For the first two points I understand them, but I don't think it's a problem. In case we consider those two reasons enough to not add a new PRC, this could be adapted to work inside generatetoaddress or generatetodescriptor adding the new arguments (payout amounts) and making them optional to keep the original behaviour if wanted. Making it backward compatible.
generateblock is capable of mining invalid blocks, since the txs to mine in the second argument can be any set of txs. We can similarly punt the calculation of the coinbase reward to the caller, so they must correctly calculate that all the values of the outputs add up to no more than the correct reward + fees. This removes the bikeshedding of whether to use remainder or split values up evenly.
This is also a good point but also focused on only this use case. Would say the same as before, you may want to mine txs from the mempool and not care about the exact amount of sats to distribute. Maybe implement this on both RPC is the solution to it.
What do you think?
andrewtoth
commented at 7:34 PM on May 12, 2025:
contributor
Consider if we already had the functionality for this in generateblock - what would be the motivation to add a new RPC generatetomany?
Note that sendtoaddress and sendmany have both been superseded by send, but the older RPCs can't easily be removed. sendall is an interesting case, which we might want to mimic instead of adding a remainder field. But, then that won't fix #31684.
andrewtoth
commented at 5:22 PM on May 13, 2025:
contributor
generateblock is thought to be used always with a given set of txs and that may not always be the use case. Maybe would be worth to implement it on both RPC?
you may want to mine txs from the mempool and not care about the exact amount of sats to distribute. Maybe implement this on both RPC is the solution to it.
What do you think?
I think you are making the case to add a feature to generateblock to mine the mempool and collect rewards the same as generateto commands. Perhaps we can make the second argument of generateblock optional, and if there is no set of txs provided then mine the mempool.
I don't think we should be duplicating the effort implementing this on more than one RPC. Then every new mining test feature needs to be duplicated (or triplicated for generatetodescriptor/generatetomany). We should deprecate generateto RPCs and just use generateblock for everything going forward, similar to send vs sendtoaddress/sendmany.
polespinasa
commented at 7:27 AM on May 14, 2025:
member
Perhaps we can make the second argument of generateblock optional, and if there is no set of txs provided then mine the mempool
That could be a smart approach. But I would always take the mempool or also put an optional argument to mine the mempool so it is not one or the other.
I don't think we should be duplicating the effort implementing this on more than one RPC. Then every new mining test feature needs to be duplicated (or triplicated for generatetodescriptor/generatetomany). We should deprecate generateto RPCs and just use generateblock for everything going forward, similar to send vs sendtoaddress/sendmany.
I might agree, will think how to build it around generateblock. Deprecation for the other RPCs can be done in another PR as I think will be a blocking reason for merging, don't want it to influence this one.
polespinasa force-pushed on May 20, 2025
polespinasa force-pushed on May 20, 2025
DrahtBot added the label CI failed on May 20, 2025
polespinasa force-pushed on May 20, 2025
polespinasa
commented at 9:58 AM on May 20, 2025:
member
Perhaps we can make the second argument of generateblock optional, and if there is no set of txs provided then mine the mempool.
This is implemented here 8b5dd8a5f135ce1aaf80d8c28943f503f4ee19d4
With a small difference, if no set of txs is provided then we mine the mempool, if an empty set is provided we mine an empty block (original behaviour of the RPC).
Note: for the moment fee collector is not implemented if a set of tx is set manually
in
src/rpc/mining.cpp:390
in
8b5dd8a5f1outdated
386 | @@ -306,10 +387,16 @@ static RPCHelpMan generateblock()
387 | return RPCHelpMan{"generateblock",
388 | "Mine a set of ordered transactions to a specified address or descriptor and return the block hash.",
389 | {
390 | - {"output", RPCArg::Type::STR, RPCArg::Optional::NO, "The address or descriptor to send the newly generated bitcoin to."}, 391 | - {"transactions", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings which are either txids or raw transactions.\n" 392 | + {"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The addresses or descriptor to split, in equal parts, the coinbase reward among.",
not sure about forcing an array, when all tests mostly just want to provide a single dummy value.
it would be good to make this optional and then, require one of output or outputs to be present, or maybe even fallback to OP_TRUE if none are given? edit: Or maybe just fallback to OP_RETURN to avoid interfering with tests that assume utxo state?
not sure about forcing an array, when all tests mostly just want to provide a single dummy value.
I don't think this should be a problem.
Same happens with sendall. Most tests just provide a single value in a list. And it actually doesn't affect many tests.
I think it keeps the code simpler and avoids the confusion that could appear if we use multiple possible arguments.
Also, even if this is not a backward compatible change it's not something critical as it is the test code.
But I like the idea of making it optional with a fallback to OP_RETURN if there are no values provided.
polespinasa
commented at 11:33 AM on May 26, 2025:
I've set "output" as optional but still I have to provide at least an empty list. I'm unable to see how to make it fully optional.
$ ./bitcoin-cli -rpcport=18443 generateblock
error code: -3
error message:
JSON value of type null is not of expected type array
DrahtBot removed the label CI failed on May 20, 2025
naiyoma
commented at 10:36 AM on May 24, 2025:
contributor
I'm a bit confused about the current approach. Are you planning to add generatetomany and also extend generateblock to accommodate an array of addresses?
I suggest that you put one approach in your fork and indicate this clearly in your description—separation of concerns makes it easier to follow and review.
For example:
Approach 1
Approach 2 → Link to the PR in your fork
polespinasa
commented at 10:40 AM on May 24, 2025:
member
I'm a bit confused about the current approach. Are you planning to add generatetomany and also extend generateblock to accommodate an array of addresses?
generatetomany will not be added. I have to delete that code.
maflcko
commented at 10:42 AM on May 24, 2025:
member
generatetomany will not be added. I have to delete that code.
Generally, it is best to just push the final version of the code, so that it is ready for further review. Prior versions of the code can trivially be retrieved via the commit hash (or a named alias), if needed.
polespinasa renamed this: rpc: generatetomany rpc: generateblock to allow multiple outputs on May 25, 2025
in
test/functional/rpc_txoutproof.py:72
in
67172f6b1boutdated
68 | @@ -69,7 +69,7 @@ def run_test(self):
69 | # We can't get the proof if we specify a non-existent block
70 | assert_raises_rpc_error(-5, "Block not found", self.nodes[0].gettxoutproof, [txid_spent], "0000000000000000000000000000000000000000000000000000000000000000")
71 | # We can't get the proof if we only have the header of the specified block
72 | - block = self.generateblock(self.nodes[0], output="raw(55)", transactions=[], submit=False) 73 | + block = self.generateblock(self.nodes[0], outputs=["raw(55)"], transactions=[], submit=False)
all those raw( can probably just be omitted and use the OP_RETURN fallback
polespinasa
commented at 11:31 AM on May 26, 2025:
done!
polespinasa force-pushed on May 26, 2025
polespinasa
commented at 11:32 AM on May 26, 2025:
member
OP_RETURN fallback if no address or descriptor set is provided.
A few tests added to test new functionalities
polespinasa force-pushed on May 26, 2025
polespinasa force-pushed on May 26, 2025
polespinasa force-pushed on May 26, 2025
in
src/rpc/mining.cpp:310
in
a4c0eecc8foutdated
305 | @@ -306,10 +306,17 @@ static RPCHelpMan generateblock()
306 | return RPCHelpMan{"generateblock",
307 | "Mine a set of ordered transactions to a specified address or descriptor and return the block hash.",
308 | {
309 | - {"output", RPCArg::Type::STR, RPCArg::Optional::NO, "The address or descriptor to send the newly generated bitcoin to."}, 310 | - {"transactions", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings which are either txids or raw transactions.\n" 311 | + {"outputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "The addresses or descriptor to split, in equal parts, the coinbase reward among.\n" 312 | + "If no outputs are provided the coinbase transaction will burn the coins into a OP_RETURN output.",
I am also thinking about splitting up the "make this arg optional". Seems like a small and easy preparatory pull request?
Any thoughts on this? Making it optional is a non-breaking change that should be easy to review.
naiyoma
commented at 1:00 PM on May 27, 2025:
contributor
A summary of my understanding of this PR so far, regarding the generateblock changes: :
Outputs and transactions are now optional.
generateblock can now take an array of addresses and distribute the reward equally among them.
generateblock with an empty array - in this case fallback to OP_TRUE
I think there's an intention to add a remainder — that way, it's possible to specify part of the reward to specific addresses and then split the remainder among the other addresses
<details>
<summary>Adding <b>how I tested</b> in case it's useful for other reviewers</summary>
Generate 2 addresses
HASH=$(./build/bin/bitcoin-cli generateblock '["bcrt1qkqjkxltw5s89kkpxg0v9560nuh8c3alu04f6d6", "bcrt1qke6n4hcu4pl2fmv9ueklnn7fz6knum2n0qcnvc"]' | jq -r .hash)
# Verify that the reward is being split equally
./build/bin/bitcoin-cli getrawtransaction $(./build/bin/bitcoin-cli getblock $HASH | jq -r .tx[0]) true | jq '.vout[] | select(.value > 0) | {address: .scriptPubKey.address, btc: .value}'
Although this RPC is only used by tests, I don't think we should be breaking backwards compatibility here. It's equally easy to determine whether this parameter is a string, so we can accept a string here for backwards compatibility.
The reason to keep compatibility is because this RPC has a high likelihood of being used in scripts and automated tests. Changing the type of the parameter will break all of those.
Yes, see verbose|verbosity in getblock for example.
polespinasa
commented at 12:08 PM on May 30, 2025:
Done in 2c855694c795a31f13a473d6a6eb80c5d765e8ed
The change causes an error in the rpc_help.py functional test that I am unable to fix
in
src/rpc/mining.cpp:312
in
a4c0eecc8foutdated
305 | @@ -306,10 +306,17 @@ static RPCHelpMan generateblock()
306 | return RPCHelpMan{"generateblock",
307 | "Mine a set of ordered transactions to a specified address or descriptor and return the block hash.",
308 | {
309 | - {"output", RPCArg::Type::STR, RPCArg::Optional::NO, "The address or descriptor to send the newly generated bitcoin to."}, 310 | - {"transactions", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings which are either txids or raw transactions.\n" 311 | + {"outputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "The addresses or descriptor to split, in equal parts, the coinbase reward among.\n" 312 | + "If no outputs are provided the coinbase transaction will burn the coins into a OP_RETURN output.", 313 | + { 314 | + {"address", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "A valid address"},
DrahtBot added the label CI failed on May 30, 2025
polespinasa force-pushed on May 30, 2025
polespinasa force-pushed on May 30, 2025
polespinasa force-pushed on May 30, 2025
polespinasa
commented at 1:19 PM on May 30, 2025:
member
Rebased on top of master.
2c855694c795a31f13a473d6a6eb80c5d765e8ed implements allowing single address or descriptor without using an array or json structure as sugested in #32468 (review) and #32468 (review). But makes rpc_help.py fail. (I still don't know why)
maflcko
commented at 9:52 AM on June 5, 2025:
member
But makes rpc_help.py fail. (I still don't know why)
The cli tool needs to "convert" non-string args. However, if the overload accepts a string and a non-string, it is unclear how to proceed. Maybe similar to hash_or_height?
polespinasa force-pushed on Jun 9, 2025
polespinasa
commented at 4:46 PM on June 9, 2025:
member
However, if the overload accepts a string and a non-string, it is unclear how to proceed. Maybe similar to hash_or_height?
I was trying to make the cli accept bitcoin-cli generateblock address but seems that the only way to do it is by requesting a json type object from the user bitcoin-cli generateblock '"address"' like hash_or_height
in
test/functional/rpc_generate.py:121
in
00a5104ea9outdated
117 | @@ -117,7 +118,7 @@ def test_generateblock(self):
118 |
119 | # Ensure that generateblock can be called concurrently by many threads.
120 | self.log.info('Generate blocks in parallel')
121 | - generate_50_blocks = lambda n: [n.generateblock(outputs=[address], transactions=[]) for _ in range(50)] 122 | + generate_50_blocks = lambda n: [n.generateblock(outputs=address, transactions=[]) for _ in range(50)]
This test fails for some unexpected reason.
It is unable to parse the address although is the same as the other tests, so format should be correct.
TestFramework (ERROR): Called Process failed with 'error: Error parsing JSON: bcrt1p9yfmy5h72durp7zrhlw9lf7jpwjgvwdg0jr0lqmmjtgg83266lqsekaqka
Maybe some of the functions used for parsing needs a lock to work correctly with concurrency?
It's the same value as in other tests that are working: See tests in lines 37, 48, 95, etc.
The value is declared in line 36 and it's never changed. It only fails in that test case.
Oh you're right, I didn't know about node.cli difference.
Thanks for the help!
polespinasa
commented at 5:02 PM on June 9, 2025:
member
00a5104ea984d75ae769a4af49d480272e8562f6
added outputs param to the RPCConvertParams lists to make rpc_help.py test pass
polespinasa force-pushed on Jun 9, 2025
DrahtBot removed the label CI failed on Jun 9, 2025
DrahtBot added the label Needs rebase on Jun 11, 2025
polespinasa force-pushed on Jun 11, 2025
polespinasa
commented at 11:08 PM on June 11, 2025:
member
Rebased on top of master 5757de4ddd37f9321ee6b338b40888fd3561fc00 to fix conflicts
DrahtBot removed the label Needs rebase on Jun 12, 2025
polespinasa force-pushed on Jun 12, 2025
polespinasa force-pushed on Jun 12, 2025
DrahtBot added the label CI failed on Jun 12, 2025
DrahtBot
commented at 7:53 AM on June 12, 2025:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task lint: https://github.com/bitcoin/bitcoin/runs/43951458497</sub>
<sub>LLM reason (✨ experimental): The CI failure is caused by a lint check failure due to release notes snippets being placed in the wrong folder.</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
polespinasa force-pushed on Jun 12, 2025
polespinasa
commented at 8:01 AM on June 12, 2025:
member
DrahtBot added the label Needs rebase on Feb 3, 2026
polespinasa force-pushed on Feb 24, 2026
polespinasa
commented at 7:22 PM on February 24, 2026:
member
Rebased to fix some conflicts and silent conflicts with master
DrahtBot removed the label Needs rebase on Feb 24, 2026
sedited requested review from naiyoma on Mar 13, 2026
sedited removed review request from naiyoma on Mar 13, 2026
sedited requested review from andrewtoth on Mar 13, 2026
sedited requested review from naiyoma on Mar 13, 2026
sedited removed review request from naiyoma on Mar 19, 2026
sedited requested review from stickies-v on Mar 19, 2026
in
src/rpc/mining.cpp:308
in
1583139317
306 | @@ -307,10 +307,19 @@ static RPCHelpMan generateblock()
307 | return RPCHelpMan{"generateblock",
308 | "Mine a set of ordered transactions to a specified address or descriptor and return the block hash.",
andrewtoth
commented at 5:47 PM on March 22, 2026:
We should update the description to mention multiple outputs.
polespinasa
commented at 7:50 AM on March 25, 2026:
andrewtoth
commented at 5:48 PM on March 22, 2026:
This if block can be combined with the below !mine_mempool block. No need to have two ifs if we are setting mine_mempool = false; unconditionally in here.
polespinasa
commented at 7:50 AM on March 25, 2026:
true, done
in
src/rpc/mining.cpp:310
in
1583139317outdated
306 | @@ -307,10 +307,19 @@ static RPCHelpMan generateblock()
307 | return RPCHelpMan{"generateblock",
308 | "Mine a set of ordered transactions to a specified address or descriptor and return the block hash.",
309 | {
310 | - {"output", RPCArg::Type::STR, RPCArg::Optional::NO, "The address or descriptor to send the newly generated bitcoin to."}, 311 | - {"transactions", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings which are either txids or raw transactions.\n" 312 | + {"outputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "The addresses or descriptors to split, in equal parts, the coinbase reward among.\n"
andrewtoth
commented at 5:51 PM on March 22, 2026:
Why don't we want to have an array of { address: amount } objects, like we do for other RPCs, and just burn the rest of the reward if there's not enough total amount?
polespinasa
commented at 7:45 AM on March 25, 2026:
in
test/functional/feature_assumeutxo.py:430
in
1583139317
426 | @@ -427,7 +427,7 @@ def run_test(self):
427 | # Create a stale block that forks off the main chain before the snapshot.
428 | temp_invalid = n0.getbestblockhash()
429 | n0.invalidateblock(temp_invalid)
430 | - stale_hash = self.generateblock(n0, output="raw(aaaa)", transactions=[], sync_fun=self.no_op)["hash"] 431 | + stale_hash = self.generateblock(n0, sync_fun=self.no_op)["hash"]
andrewtoth
commented at 5:53 PM on March 22, 2026:
I think the only thing we should touch in the existing functional tests is renaming output -> outputs. Otherwise this should be backwards compatible, and mining the mempool instead of an empty block can be a behavior change in the tests.
polespinasa
commented at 7:51 AM on March 25, 2026:
As this suggest #32468 (review) the raw(aaa) can be removed to just fallback on the OP_RETURN.
And doing outputs=[] or not adding outputs at all is the same, so there's no need to keep it.
I will add back the transactions=[] you are right that is a behavior change and this PR should not be changing that. Thanks.
polespinasa force-pushed on Mar 25, 2026
polespinasa
commented at 8:13 AM on March 25, 2026:
member
Force pushed to apply some of @andrewtoth suggestions as they were fast to implement.
And rebased on top of master.
polespinasa
commented at 2:59 PM on April 20, 2026:
member
I need to take some time to implement the split reward option proposed here #32468 (comment) and already been worked on here polespinasa#1.
Is this supposed to be implemented here now?
As mentioned before #32468 (comment), I think this PR is good as is and custom rewards split can be implemented in a follow-up PR. Unless reviewers consider it must be included in this PR, in that case I will be happy to work on it here.
stickies-v
commented at 3:10 PM on April 21, 2026:
contributor
I think this PR is good as is and custom rewards split can be implemented in a follow-up PR.
Custom rewards are the general solution, why not just implement that right away? It's useful to keep the CLI commands ergonomic, but I think it's a mistake to handicap the RPC interface just to make CLI more ergonomic. The RPC interface should be maximally useful on its own.
It also looks like this work should be split up in multiple commits, I think the outputs changes and the mempool changes are orthogonal?
DrahtBot added the label Needs rebase on May 17, 2026
polespinasa force-pushed on May 18, 2026
DrahtBot removed the label Needs rebase on May 18, 2026
polespinasa force-pushed on May 18, 2026
DrahtBot added the label CI failed on May 18, 2026
polespinasa force-pushed on May 18, 2026
polespinasa
commented at 9:42 PM on May 18, 2026:
member
It also looks like this work should be split up in multiple commits, I think the outputs changes and the mempool changes are orthogonal?
Working on it. Idk why I structured it so bad in the first place 😅
Custom rewards are the general solution, why not just implement that right away?
DrahtBot removed the label CI failed on May 19, 2026
polespinasa force-pushed on May 19, 2026
polespinasa force-pushed on May 19, 2026
DrahtBot added the label CI failed on May 19, 2026
DrahtBot
commented at 9:06 PM on May 19, 2026:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/26125045455/job/76836499987</sub>
<sub>LLM reason (✨ experimental): CI failed because the lint check rpc_assert found a fatal assertion (assert/CHECK_NONFATAL violation) in src/rpc/mining.cpp.</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
DrahtBot removed the label CI failed on May 19, 2026
polespinasa marked this as a draft on May 20, 2026
polespinasa
commented at 1:27 PM on May 20, 2026:
member
Moved to draft while working on custom rewards and cleaning the commit structure
polespinasa force-pushed on Aug 27, 2026
polespinasa force-pushed on Aug 27, 2026
DrahtBot added the label CI failed on Aug 27, 2026
DrahtBot removed the label CI failed on Aug 27, 2026
polespinasa force-pushed on Sep 16, 2026
polespinasa force-pushed on Sep 16, 2026
polespinasa marked this as ready for review on Sep 16, 2026
polespinasa
commented at 6:35 PM on September 16, 2026:
member
Marking this as ready for review.
Bicaru20 implemented the custom split rewards.
The PR was also rebased on top of master and corrected some nits and inconsistencies that I found.
DrahtBot added the label Needs rebase on Sep 24, 2026
polespinasa force-pushed on Sep 24, 2026
polespinasa
commented at 8:21 AM on September 24, 2026:
member
Rebased on top of master
DrahtBot removed the label Needs rebase on Sep 24, 2026
DrahtBot added the label Needs rebase on Nov 5, 2026
polespinasa force-pushed on Nov 5, 2026
DrahtBot removed the label Needs rebase on Nov 5, 2026
polespinasa renamed this: rpc: generateblock to allow multiple outputs rpc: generateblock to allow multiple outputs with custom payouts on Nov 10, 2026
polespinasa force-pushed on Nov 10, 2026
polespinasa
commented at 5:37 PM on November 10, 2026:
member
Force pushed to address the major issue reported by Ralph, which is a bit tricky to trigger and does not matter at all because this is a test RPC, but the solution is easy enough to just fix it.
polespinasa force-pushed on Nov 10, 2026
polespinasa
commented at 10:06 PM on November 10, 2026:
member
@Bicaru20 maybe you want to review the last changes, I fixed the two main issues that Ralph reported.
in
doc/release-notes-32468.md:5
in
a6ce1200ea
0 | @@ -0,0 +1,5 @@ 1 | +# RPC 2 | + 3 | +- The RPC `generateblock` takes `output` as an argument. This argument allows to specify where to distribute the reward of the block. It takes an address, a descriptor or a list of multiple addresses and descriptors. Optionally, each entry can be an object `{"address/descriptor": amount}` to assign that output a fixed reward in satoshis; the remaining block reward is then split, in equal parts, among all provided outputs. If `output` is not set, the reward is burnt in an OP_RETURN output. The reward is split, in equal parts, among all addresses and descriptors provided. 4 | + 5 | +- The argument `transactions` is optional in `generateblock`. If no set of transactions is provided, the ones from the mempool are used. If an empty set is provided, an empty block is mined. If a set of transactions is provided, that set of transactions is mined.
fanquake
commented at 12:46 PM on November 12, 2026:
- The argument `transactions` is optional in `generateblock`. If no set of transactions is provided, the ones from the mempool are used. If an empty set is provided, an empty block is mined. If a set of transactions is provided, that set of transactions is mined. (#32468)
polespinasa
commented at 8:01 AM on November 13, 2026:
done
polespinasa force-pushed on Nov 13, 2026
DrahtBot added the label Needs rebase on Nov 16, 2026
Allow generateblock to mine empty blocks, blocks with a pre-set of transactions or
mine transactions from the mempool.
547e7adc7b
test: expand generateblock test coverage7b4f0efef0
polespinasa force-pushed on Nov 19, 2026
rpc: add multiple outputs to generateblock
Allow to add multiple outputs to the coinbase transaction when using generateblock.
The block reward, previously burned is now splited in equal parts among the different outputs.
If the reward is odd, the first N outputs get an extra sat. Being N = total_reward % num_outputs.
94c5b8df11
test: add custom outputs test coverage for generateblock
Also remove now unecesary raw outputs from other tests consuming
the generateblock rpc.
ed6fed3177
rpc: add custom split reward to generateblock
Allows to specify custom rewards for each output of the coinbase transaction.
Previously the reward was split into equal parts.
Co-authored-by: Biel <bicaru2@gmail.com>
42988c457c
test: add test coverage for custom reward of generateblock08be0e190d
Add release notes
Co-authored-by: Biel <bicaru2@gmail.com>
cfd263e3f6
polespinasa force-pushed on Nov 19, 2026
DrahtBot added the label CI failed on Nov 19, 2026
DrahtBot
commented at 11:34 AM on November 19, 2026:
contributor
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task FreeBSD Cross: https://github.com/bitcoin/bitcoin/actions/runs/44514082605/job/135525447174</sub>
<sub>LLM reason (✨ experimental): CI failed to compile rpc/mining.cpp: CHECK_NONFATAL(block_template) applies ! to a util::NotNull<std::unique_ptr<...>>, which is an invalid type.</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
DrahtBot removed the label Needs rebase on Nov 19, 2026
polespinasa
commented at 1:02 PM on November 19, 2026:
member
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-11-21 11:52 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me