Skip to content

rpc: mine to the wallet selected on the setgenerate endpoint (#450)#457

Open
JSanchezFDZ wants to merge 1 commit into
Raptor3um:developfrom
JSanchezFDZ:fix/setgenerate-mine-to-selected-wallet
Open

rpc: mine to the wallet selected on the setgenerate endpoint (#450)#457
JSanchezFDZ wants to merge 1 commit into
Raptor3um:developfrom
JSanchezFDZ:fix/setgenerate-mine-to-selected-wallet

Conversation

@JSanchezFDZ

Copy link
Copy Markdown

Problem

setgenerate always routed the coinbase rewards to the first loaded wallet
(GetFirstWallet), ignoring which wallet the call was made against. In a
multi-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:

  • setgenerate reads it with GetWalletNameFromJSONRPCRequest (no throw when no
    wallet is specified, so CLI/single-wallet use is unchanged),
  • passes it to GenerateRaptoreums(..., walletName),
  • RaptoreumMiner resolves it with GetWallet and falls back to GetFirstWallet
    when the name is empty or the wallet is not loaded.

GetWalletNameFromJSONRPCRequest is now declared in wallet/rpcwallet.h so the
mining RPC can use it (guarded by ENABLE_WALLET).

Testing

Compile-validated on develop with --enable-wallet (miner.cpp, rpc/mining.cpp,
wallet/rpcwallet.cpp all build cleanly). The actual reward routing was not
exercised at runtime: setgenerate is 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant