rpc: mine to the wallet selected on the setgenerate endpoint (#450)#457
Open
JSanchezFDZ wants to merge 1 commit into
Open
rpc: mine to the wallet selected on the setgenerate endpoint (#450)#457JSanchezFDZ wants to merge 1 commit into
JSanchezFDZ wants to merge 1 commit into
Conversation
…um#450) setgenerate always routed coinbase rewards to the first loaded wallet (GetFirstWallet) regardless of which wallet was selected, so in multi-wallet setups the rewards went to the default wallet instead of the one chosen in the GUI console. Thread the wallet name from the /wallet/<name> RPC endpoint down to the miner: setgenerate reads it with GetWalletNameFromJSONRPCRequest, passes it to GenerateRaptoreums, and RaptoreumMiner resolves it with GetWallet, falling back to the first loaded wallet when no wallet was specified. CLI and single-wallet usage are unchanged and the multi-wallet "wallet not specified" throw is avoided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
setgeneratealways routed the coinbase rewards to the first loaded wallet(
GetFirstWallet), ignoring which wallet the call was made against. In amulti-wallet setup the rewards therefore went to the default wallet instead of
the one selected in the GUI console (issue #450).
Change
Thread the wallet name from the
/wallet/<name>RPC endpoint down to the miner:setgeneratereads it withGetWalletNameFromJSONRPCRequest(no throw when nowallet is specified, so CLI/single-wallet use is unchanged),
GenerateRaptoreums(..., walletName),RaptoreumMinerresolves it withGetWalletand falls back toGetFirstWalletwhen the name is empty or the wallet is not loaded.
GetWalletNameFromJSONRPCRequestis now declared inwallet/rpcwallet.hso themining RPC can use it (guarded by
ENABLE_WALLET).Testing
Compile-validated on
developwith--enable-wallet(miner.cpp, rpc/mining.cpp,wallet/rpcwallet.cpp all build cleanly). The actual reward routing was not
exercised at runtime:
setgenerateis rejected on regtest (MineBlocksOnDemand)and observing a real coinbase requires mining on a live network. A maintainer
with a mining setup can confirm by selecting a non-default wallet and checking
the coinbase destination. The change is backward compatible — with no wallet
endpoint the behaviour is identical to before.
Closes #450.