Skip to content

Commit

Permalink
wallet: Add HasWallets
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Apr 18, 2018
1 parent 432ea7d commit ac0de44
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rpc/misc.cpp
Expand Up @@ -69,7 +69,7 @@ UniValue validateaddress(const JSONRPCRequest& request)
{

#ifdef ENABLE_WALLET
if (!GetWallets().empty() && IsDeprecatedRPCEnabled("validateaddress")) {
if (HasWallets() && IsDeprecatedRPCEnabled("validateaddress")) {
ret.pushKVs(getaddressinfo(request));
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.cpp
Expand Up @@ -66,7 +66,7 @@ bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException)
{
if (pwallet) return true;
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
Expand Down
5 changes: 5 additions & 0 deletions src/wallet/wallet.cpp
Expand Up @@ -50,6 +50,11 @@ void RemoveWallet(CWallet* wallet)
if (i != vpwallets.end()) vpwallets.erase(i);
}

bool HasWallets()
{
return !vpwallets.empty();
}

std::vector<CWallet*> GetWallets()
{
return vpwallets;
Expand Down
1 change: 1 addition & 0 deletions src/wallet/wallet.h
Expand Up @@ -34,6 +34,7 @@

void AddWallet(CWallet* wallet);
void RemoveWallet(CWallet* wallet);
bool HasWallets();
std::vector<CWallet*> GetWallets();
CWallet* GetWallet(const std::string& name);

Expand Down

0 comments on commit ac0de44

Please sign in to comment.