Skip to content

Commit 3c058fd

Browse files
committed
wallet: Add HasWallets
1 parent 373aee2 commit 3c058fd

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/rpc/misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ UniValue validateaddress(const JSONRPCRequest& request)
6969
{
7070

7171
#ifdef ENABLE_WALLET
72-
if (!GetWallets().empty() && IsDeprecatedRPCEnabled("validateaddress")) {
72+
if (HasWallets() && IsDeprecatedRPCEnabled("validateaddress")) {
7373
ret.pushKVs(getaddressinfo(request));
7474
}
7575
#endif

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException)
6666
{
6767
if (pwallet) return true;
6868
if (avoidException) return false;
69-
if (GetWallets().empty()) {
69+
if (!HasWallets()) {
7070
// Note: It isn't currently possible to trigger this error because
7171
// wallet RPC methods aren't registered unless a wallet is loaded. But
7272
// this error is being kept as a precaution, because it's possible in

src/wallet/wallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ bool RemoveWallet(CWallet* wallet)
5454
return true;
5555
}
5656

57+
bool HasWallets()
58+
{
59+
return !vpwallets.empty();
60+
}
61+
5762
std::vector<CWallet*> GetWallets()
5863
{
5964
return vpwallets;

src/wallet/wallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
bool AddWallet(CWallet* wallet);
3636
bool RemoveWallet(CWallet* wallet);
37+
bool HasWallets();
3738
std::vector<CWallet*> GetWallets();
3839
CWallet* GetWallet(const std::string& name);
3940

0 commit comments

Comments
 (0)