diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -78,8 +78,7 @@ if (isValid) { #ifdef ENABLE_WALLET - if (!GetWallets().empty() && - IsDeprecatedRPCEnabled(gArgs, "validateaddress")) { + if (HasWallets() && IsDeprecatedRPCEnabled(gArgs, "validateaddress")) { ret.pushKVs(getaddressinfo(config, request)); } #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -85,7 +85,7 @@ if (avoidException) { return false; } - if (GetWallets().empty()) { + if (!HasWallets()) { // Note: It isn't currently possible to trigger this error because // wallet RPC methods aren't registered unless a wallet is loaded. But // this error is being kept as a precaution, because it's possible in diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -33,6 +33,7 @@ bool AddWallet(CWallet *wallet); bool RemoveWallet(CWallet *wallet); +bool HasWallets(); std::vector GetWallets(); CWallet *GetWallet(const std::string &name); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -66,6 +66,10 @@ return true; } +bool HasWallets() { + return !vpwallets.empty(); +} + std::vector GetWallets() { return vpwallets; }