diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-03-01 17:03:52 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-06-24 13:49:22 -0400 |
commit | 74fede3b8ba69e2cc82c617cdf406ab79df58825 (patch) | |
tree | 8d5e969d58e535cab4c7cbb7099f39dedf8154df /src/wallet/wallet.cpp | |
parent | 432ba9e5434da90d2cf680f23e8c7b7164c9f945 (diff) |
wallet: Upgrade existing descriptor caches
Add functions to upgrade existing descriptor caches to support the use
of last hardened xpub caching.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c2586b60b8..ab071a7329 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -374,6 +374,19 @@ void CWallet::UpgradeKeyMetadata() SetWalletFlag(WALLET_FLAG_KEY_ORIGIN_METADATA); } +void CWallet::UpgradeDescriptorCache() +{ + if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) || IsLocked() || IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) { + return; + } + + for (ScriptPubKeyMan* spkm : GetAllScriptPubKeyMans()) { + DescriptorScriptPubKeyMan* desc_spkm = dynamic_cast<DescriptorScriptPubKeyMan*>(spkm); + desc_spkm->UpgradeDescriptorCache(); + } + SetWalletFlag(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED); +} + bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys) { CCrypter crypter; @@ -390,6 +403,8 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool accept_no_key if (Unlock(_vMasterKey, accept_no_keys)) { // Now that we've unlocked, upgrade the key metadata UpgradeKeyMetadata(); + // Now that we've unlocked, upgrade the descriptor cache + UpgradeDescriptorCache(); return true; } } |