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 19, 2019
1 parent 1196696 commit dcbbb75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 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.
18 changes: 17 additions & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,16 @@ static void GetWalletBalances(UniValue& result)
*/
static UniValue GetNewAddress()
{
<<<<<<< HEAD
std::optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
||||||| merged common ancestors
Optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
=======
Optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet") && !gArgs.IsArgNegated("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
>>>>>>> Fix nonsensical bitcoin-cli -norpcwallet behavior
DefaultRequestHandler rh;
return ConnectAndCallRPC(&rh, "getnewaddress", /* args=*/{}, wallet_name);
}
Expand Down Expand Up @@ -924,15 +932,23 @@ static int CommandLineRPC(int argc, char *argv[])
}
if (nRet == 0) {
// Perform RPC call
<<<<<<< HEAD
std::optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
||||||| merged common ancestors
Optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
=======
Optional<std::string> wallet_name{};
if (gArgs.IsArgSet("-rpcwallet") && !gArgs.IsArgNegated("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", "");
>>>>>>> Fix nonsensical bitcoin-cli -norpcwallet behavior
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 dcbbb75

Please sign in to comment.