aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-10-07 14:11:34 -0400
committerAndrew Chow <achow101-github@achow101.com>2019-11-01 22:58:05 -0400
commit7ef47b88e67718766c92d23973742d08436176e0 (patch)
tree33e85f9d2ebcca00a3b000fd9d69e8d2462703d1 /src
parent089e17d45c8147bd0303bcbf02dc0f7d6b387f2a (diff)
Refactor: Move GetKeypoolSize code out of CWallet
This commit does not change behavior.
Diffstat (limited to 'src')
-rw-r--r--src/wallet/scriptpubkeyman.cpp6
-rw-r--r--src/wallet/scriptpubkeyman.h2
-rw-r--r--src/wallet/wallet.cpp11
-rw-r--r--src/wallet/wallet.h8
4 files changed, 20 insertions, 7 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 8c3a2a831a..a046a7c93e 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -464,6 +464,12 @@ size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys()
return setExternalKeyPool.size() + set_pre_split_keypool.size();
}
+unsigned int LegacyScriptPubKeyMan::GetKeyPoolSize() const
+{
+ AssertLockHeld(cs_wallet);
+ return setInternalKeyPool.size() + setExternalKeyPool.size();
+}
+
const CKeyMetadata* LegacyScriptPubKeyMan::GetMetadata(uint160 id) const
{
AssertLockHeld(cs_wallet);
diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h
index 24b0a27881..b9722ea63f 100644
--- a/src/wallet/scriptpubkeyman.h
+++ b/src/wallet/scriptpubkeyman.h
@@ -182,6 +182,7 @@ public:
virtual int64_t GetOldestKeyPoolTime() { return GetTime(); }
virtual size_t KeypoolCountExternalKeys() { return 0; }
+ virtual unsigned int GetKeyPoolSize() const { return 0; }
virtual const CKeyMetadata* GetMetadata(uint160 id) const { return nullptr; }
};
@@ -295,6 +296,7 @@ public:
int64_t GetOldestKeyPoolTime() override;
size_t KeypoolCountExternalKeys() override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ unsigned int GetKeyPoolSize() const override;
const CKeyMetadata* GetMetadata(uint160 id) const override;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 575ae7e044..3dff6f7d61 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3027,6 +3027,17 @@ size_t CWallet::KeypoolCountExternalKeys()
return count;
}
+unsigned int CWallet::GetKeyPoolSize() const
+{
+ AssertLockHeld(cs_wallet);
+
+ unsigned int count = 0;
+ if (auto spk_man = m_spk_man.get()) {
+ count += spk_man->GetKeyPoolSize();
+ }
+ return count;
+}
+
bool CWallet::TopUpKeyPool(unsigned int kpSize)
{
bool res = true;
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 2a80395644..49c27eb9f6 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -992,11 +992,7 @@ public:
bool DelAddressBook(const CTxDestination& address);
- unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
- {
- AssertLockHeld(cs_wallet);
- return setInternalKeyPool.size() + setExternalKeyPool.size();
- }
+ unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
//! signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower
void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr, bool fExplicit = false) override;
@@ -1131,8 +1127,6 @@ public:
LegacyScriptPubKeyMan::WatchOnlySet& setWatchOnly GUARDED_BY(cs_KeyStore) = m_spk_man->setWatchOnly;
LegacyScriptPubKeyMan::WatchKeyMap& mapWatchKeys GUARDED_BY(cs_KeyStore) = m_spk_man->mapWatchKeys;
WalletBatch*& encrypted_batch GUARDED_BY(cs_wallet) = m_spk_man->encrypted_batch;
- std::set<int64_t>& setInternalKeyPool GUARDED_BY(cs_wallet) = m_spk_man->setInternalKeyPool;
- std::set<int64_t>& setExternalKeyPool GUARDED_BY(cs_wallet) = m_spk_man->setExternalKeyPool;
int64_t& nTimeFirstKey GUARDED_BY(cs_wallet) = m_spk_man->nTimeFirstKey;
using CryptedKeyMap = LegacyScriptPubKeyMan::CryptedKeyMap;
};