Skip to content

Commit

Permalink
Fix nonsensical bitcoin-cli -norpcwallet behavior
Browse files Browse the repository at this point in the history
Treat specifying -norpcwallet exactly the same as not specifying any -rpcwallet
option, instead of treating it like -rpcwallet=0 with 0 as the wallet name.

This restores previous behavior before 7430775
from bitcoin#18594, which inadvertently changed
it.
  • Loading branch information
ryanofsky committed Dec 30, 2021
1 parent af1a30c commit 98ebf0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/release-notes-17783.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Configuration
-------------

Some corner cases handling negated list options `-norpcallowip`, `-norpcbind`, `-nobind`, `-nowhitebind`, `-noconnect`, `-noexternalip`, `-noonlynet`, `-nosignetchallenge`, `-nosignetseednode` have been fixed. Now negating these options is the same as not specifying them at all.
Some corner cases handling negated list options `-norpcallowip`, `-norpcbind`, `-nobind`, `-nowhitebind`, `-noconnect`, `-noexternalip`, `-noonlynet`, `-nosignetchallenge`, `-nosignetseednode`, `-norpcwallet` have been fixed. Now negating these options is the same as not specifying them at all.
6 changes: 3 additions & 3 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ static void ParseGetInfoResult(UniValue& result)
static UniValue GetNewAddress()
{
std::optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
if (gArgs.IsArgSet("-rpcwallet") && !gArgs.IsArgNegated("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
DefaultRequestHandler rh;
return ConnectAndCallRPC(&rh, "getnewaddress", /* args=*/{}, wallet_name);
}
Expand Down Expand Up @@ -1168,15 +1168,15 @@ static int CommandLineRPC(int argc, char *argv[])
if (nRet == 0) {
// Perform RPC call
std::optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
if (gArgs.IsArgSet("-rpcwallet") && !gArgs.IsArgNegated("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
const UniValue reply = ConnectAndCallRPC(rh.get(), method, args, wallet_name);

// Parse reply
UniValue result = find_value(reply, "result");
const UniValue& error = find_value(reply, "error");
if (error.isNull()) {
if (gArgs.GetBoolArg("-getinfo", false)) {
if (!gArgs.IsArgSet("-rpcwallet")) {
if (!gArgs.IsArgSet("-rpcwallet") || gArgs.IsArgNegated("-rpcwallet")) {
GetWalletBalances(result); // fetch multiwallet balances and append to result
}
ParseGetInfoResult(result);
Expand Down

0 comments on commit 98ebf0b

Please sign in to comment.