wallet: Upgrade existing descriptor caches

Add functions to upgrade existing descriptor caches to support the use
of last hardened xpub caching.
This commit is contained in:
Andrew Chow
2021-03-01 17:03:52 -05:00
parent 432ba9e543
commit 74fede3b8b
6 changed files with 62 additions and 0 deletions

View File

@@ -884,6 +884,14 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
result = DBErrors::CORRUPT;
}
// Upgrade all of the descriptor caches to cache the last hardened xpub
// This operation is not atomic, but if it fails, only new entries are added so it is backwards compatible
try {
pwallet->UpgradeDescriptorCache();
} catch (...) {
result = DBErrors::CORRUPT;
}
// Set the inactive chain
if (wss.m_hd_chains.size() > 0) {
LegacyScriptPubKeyMan* legacy_spkm = pwallet->GetLegacyScriptPubKeyMan();