Skip to content

Commit b1f59d5

Browse files
committed
RPC/Wallet: unloadwallet: Clarify docs/error when both the RPC endpoint and wallet_name parameter specify a wallet
1 parent 831675c commit b1f59d5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,7 +2792,7 @@ static RPCHelpMan unloadwallet()
27922792
"Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
27932793
"Specifying the wallet name on a wallet endpoint is invalid.",
27942794
{
2795-
{"wallet_name", RPCArg::Type::STR, /* default */ "the wallet name from the RPC request", "The name of the wallet to unload."},
2795+
{"wallet_name", RPCArg::Type::STR, /* default */ "the wallet name from the RPC endpoint", "The name of the wallet to unload. Must be provided in the RPC endpoint or this parameter (but not both)."},
27962796
{"load_on_startup", RPCArg::Type::BOOL, /* default */ "null", "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
27972797
},
27982798
RPCResult{RPCResult::Type::OBJ, "", "", {
@@ -2807,7 +2807,7 @@ static RPCHelpMan unloadwallet()
28072807
std::string wallet_name;
28082808
if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
28092809
if (!request.params[0].isNull()) {
2810-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot unload the requested wallet");
2810+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Both the RPC endpoint wallet and wallet_name parameter were provided (only one allowed)");
28112811
}
28122812
} else {
28132813
wallet_name = request.params[0].get_str();

test/functional/wallet_multiwallet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ def wallet_file(name):
355355
assert_raises_rpc_error(-1, "JSON value is not a string as expected", self.nodes[0].unloadwallet)
356356
assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", self.nodes[0].unloadwallet, "dummy")
357357
assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", node.get_wallet_rpc("dummy").unloadwallet)
358-
assert_raises_rpc_error(-8, "Cannot unload the requested wallet", w1.unloadwallet, "w2"),
358+
assert_raises_rpc_error(-8, "Both the RPC endpoint wallet and wallet_name parameter were provided (only one allowed)", w1.unloadwallet, "w2"),
359+
assert_raises_rpc_error(-8, "Both the RPC endpoint wallet and wallet_name parameter were provided (only one allowed)", w1.unloadwallet, "w1"),
359360

360361
# Successfully unload the specified wallet name
361362
self.nodes[0].unloadwallet("w1")

0 commit comments

Comments
 (0)