Skip to content

Commit 8cd0b86

Browse files
committed
wallet: make CanGetAddresses() const
CWallet::CanGetAddresses() is used to check whether the wallet has available or is able to produce keys for addresses. It uses the ScriptPubKeyMan::CanGetAddresses(), which in turn uses the const KeypoolCountExternalKeys() method, all which do counting and no modifications.
1 parent 037fa77 commit 8cd0b86

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/interfaces/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ class WalletImpl : public Wallet
468468
}
469469
unsigned int getConfirmTarget() override { return m_wallet->m_confirm_target; }
470470
bool hdEnabled() override { return m_wallet->IsHDEnabled(); }
471-
bool canGetAddresses() override { return m_wallet->CanGetAddresses(); }
471+
bool canGetAddresses() const override { return m_wallet->CanGetAddresses(); }
472472
bool IsWalletFlagSet(uint64_t flag) override { return m_wallet->IsWalletFlagSet(flag); }
473473
OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; }
474474
OutputType getDefaultChangeType() override { return m_wallet->m_default_change_type; }

src/interfaces/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class Wallet
246246
virtual bool hdEnabled() = 0;
247247

248248
// Return whether the wallet is blank.
249-
virtual bool canGetAddresses() = 0;
249+
virtual bool canGetAddresses() const = 0;
250250

251251
// check if a certain wallet flag is set.
252252
virtual bool IsWalletFlagSet(uint64_t flag) = 0;

src/wallet/scriptpubkeyman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool LegacyScriptPubKeyMan::IsHDEnabled() const
358358
return !hdChain.seed_id.IsNull();
359359
}
360360

361-
bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal)
361+
bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal) const
362362
{
363363
LOCK(cs_KeyStore);
364364
// Check if the keypool has keys

src/wallet/scriptpubkeyman.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class ScriptPubKeyMan
184184
virtual bool IsHDEnabled() const { return false; }
185185

186186
/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
187-
virtual bool CanGetAddresses(bool internal = false) { return false; }
187+
virtual bool CanGetAddresses(bool internal = false) const { return false; }
188188

189189
/** Upgrades the wallet to the specified version */
190190
virtual bool Upgrade(int prev_version, std::string& error) { return false; }
@@ -344,7 +344,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
344344

345345
const CKeyMetadata* GetMetadata(const CTxDestination& dest) const override;
346346

347-
bool CanGetAddresses(bool internal = false) override;
347+
bool CanGetAddresses(bool internal = false) const override;
348348

349349
std::unique_ptr<SigningProvider> GetSigningProvider(const CScript& script) const override;
350350

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ bool CWallet::IsHDEnabled() const
13331333
return result;
13341334
}
13351335

1336-
bool CWallet::CanGetAddresses(bool internal)
1336+
bool CWallet::CanGetAddresses(bool internal) const
13371337
{
13381338
LOCK(cs_wallet);
13391339
if (m_spk_managers.empty()) return false;

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ class CWallet final : public WalletStorage, private interfaces::Chain::Notificat
11041104
bool IsHDEnabled() const;
11051105

11061106
/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
1107-
bool CanGetAddresses(bool internal = false);
1107+
bool CanGetAddresses(bool internal = false) const;
11081108

11091109
/**
11101110
* Blocks until the wallet state is up-to-date to /at least/ the current

0 commit comments

Comments
 (0)