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 Jun 16, 2021
1 parent 9c0e697 commit 048a4ee
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` 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`, `-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 @@ -874,7 +874,7 @@ static void GetWalletBalances(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 @@ -981,14 +981,14 @@ 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.IsArgSet("-getinfo") && !gArgs.IsArgSet("-rpcwallet")) {
if (gArgs.IsArgSet("-getinfo") && (!gArgs.IsArgSet("-rpcwallet") || gArgs.IsArgNegated("-rpcwallet"))) {
GetWalletBalances(result); // fetch multiwallet balances and append to result
}
ParseResult(result, strPrint);
Expand Down

0 comments on commit 048a4ee

Please sign in to comment.