Refactor: Move RewriteDB code out of CWallet

This commit does not change behavior.
This commit is contained in:
Andrew Chow
2019-10-07 14:11:34 -04:00
parent 0eac7088ab
commit 089e17d45c
3 changed files with 25 additions and 19 deletions

View File

@@ -415,6 +415,17 @@ bool LegacyScriptPubKeyMan::HavePrivateKeys() const
return !mapKeys.empty() || !mapCryptedKeys.empty();
}
void LegacyScriptPubKeyMan::RewriteDB()
{
AssertLockHeld(cs_wallet);
setInternalKeyPool.clear();
setExternalKeyPool.clear();
m_pool_key_to_index.clear();
// Note: can't top-up keypool here, because wallet is locked.
// User will be prompted to unlock wallet the next operation
// that requires a new key.
}
static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, WalletBatch& batch) {
if (setKeyPool.empty()) {
return GetTime();