From 98ebf0b32a6deb6f14b919286e2c3195ab68ab6d Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Thu, 19 Dec 2019 18:00:04 -0500 Subject: [PATCH] Fix nonsensical bitcoin-cli -norpcwallet behavior 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 743077544b5420246ef29e0b708c90e3a8dfeeb6 from https://github.com/bitcoin/bitcoin/pull/18594, which inadvertently changed it. --- doc/release-notes-17783.md | 2 +- src/bitcoin-cli.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/release-notes-17783.md b/doc/release-notes-17783.md index a2fb1fdc533f6..9f51fcf2a5310 100644 --- a/doc/release-notes-17783.md +++ b/doc/release-notes-17783.md @@ -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. diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 279521a761311..bb11c1a1ae98b 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -1061,7 +1061,7 @@ static void ParseGetInfoResult(UniValue& result) static UniValue GetNewAddress() { std::optional 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); } @@ -1168,7 +1168,7 @@ static int CommandLineRPC(int argc, char *argv[]) if (nRet == 0) { // Perform RPC call std::optional 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 @@ -1176,7 +1176,7 @@ static int CommandLineRPC(int argc, char *argv[]) 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);