diff options
| author | Karl-Johan Alm <[email protected]> | 2020-03-02 16:35:58 +0900 |
|---|---|---|
| committer | Karl-Johan Alm <[email protected]> | 2020-03-02 17:26:30 +0900 |
| commit | 8cd0b86340870d8f359e4ae26880e03ea36818ab (patch) | |
| tree | b25041df17bf166b6a3750b8c57ef4c6bdbe6f87 /src | |
| parent | wallet: make KeypoolCountExternalKeys() const (diff) | |
| download | discoin-8cd0b86340870d8f359e4ae26880e03ea36818ab.tar.xz discoin-8cd0b86340870d8f359e4ae26880e03ea36818ab.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/interfaces/wallet.cpp | 2 | ||||
| -rw-r--r-- | src/interfaces/wallet.h | 2 | ||||
| -rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 2 | ||||
| -rw-r--r-- | src/wallet/scriptpubkeyman.h | 4 | ||||
| -rw-r--r-- | src/wallet/wallet.cpp | 2 | ||||
| -rw-r--r-- | src/wallet/wallet.h | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index baea71d0b..7ddf3b22e 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -468,7 +468,7 @@ public: } unsigned int getConfirmTarget() override { return m_wallet->m_confirm_target; } bool hdEnabled() override { return m_wallet->IsHDEnabled(); } - bool canGetAddresses() override { return m_wallet->CanGetAddresses(); } + bool canGetAddresses() const override { return m_wallet->CanGetAddresses(); } bool IsWalletFlagSet(uint64_t flag) override { return m_wallet->IsWalletFlagSet(flag); } OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; } OutputType getDefaultChangeType() override { return m_wallet->m_default_change_type; } diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index d4280e809..435125341 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -246,7 +246,7 @@ public: virtual bool hdEnabled() = 0; // Return whether the wallet is blank. - virtual bool canGetAddresses() = 0; + virtual bool canGetAddresses() const = 0; // check if a certain wallet flag is set. virtual bool IsWalletFlagSet(uint64_t flag) = 0; diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index defe2f0a9..8ff00e802 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -358,7 +358,7 @@ bool LegacyScriptPubKeyMan::IsHDEnabled() const return !hdChain.seed_id.IsNull(); } -bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal) +bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal) const { LOCK(cs_KeyStore); // Check if the keypool has keys diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 213084c52..9d227ad3b 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -184,7 +184,7 @@ public: virtual bool IsHDEnabled() const { return false; } /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */ - virtual bool CanGetAddresses(bool internal = false) { return false; } + virtual bool CanGetAddresses(bool internal = false) const { return false; } /** Upgrades the wallet to the specified version */ virtual bool Upgrade(int prev_version, std::string& error) { return false; } @@ -344,7 +344,7 @@ public: const CKeyMetadata* GetMetadata(const CTxDestination& dest) const override; - bool CanGetAddresses(bool internal = false) override; + bool CanGetAddresses(bool internal = false) const override; std::unique_ptr<SigningProvider> GetSigningProvider(const CScript& script) const override; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 009c44332..8f6dbbad5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1333,7 +1333,7 @@ bool CWallet::IsHDEnabled() const return result; } -bool CWallet::CanGetAddresses(bool internal) +bool CWallet::CanGetAddresses(bool internal) const { LOCK(cs_wallet); if (m_spk_managers.empty()) return false; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 63ca54508..1dd9f779a 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1104,7 +1104,7 @@ public: bool IsHDEnabled() const; /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */ - bool CanGetAddresses(bool internal = false); + bool CanGetAddresses(bool internal = false) const; /** * Blocks until the wallet state is up-to-date to /at least/ the current |