Remove dead code due to legacy wallet removal.
Leftovers from previous #32481.
Note:
While attempting to remove the legacy check in CWallet::UpgradeDescriptorCache() (which is called from DBErrors WalletBatch::LoadWallet(CWallet* pwallet)), I once again ran into the fact that LoadWallet() is used in two distinct scenarios — something I was already aware of:
- Wallet creation – the upgrade is ignored here because no wallet flags are yet set; attempting to set a flag (ie
WALLET_FLAG_LAST_HARDENED_XPUB_CACHEDat the end of the upgrade function, if the legacy check is removed) would produce a failure (DBErrors CWallet::LoadWallet()->Assert(m_wallet_flags == 0)). - Wallet loading – the upgrade proceeds correctly and the flag
WALLET_FLAG_LAST_HARDENED_XPUB_CACHEDis set.
While revisiting this, I also noticed that some LoadWallet() calls in the wallet tests are unnecessary and I’ve removed them in the first commit.
The following change in UpgradeDescriptorCache() could be done in PR #32636 as part of the separation between wallet loading and creation responsibilities.
0
1 void CWallet::UpgradeDescriptorCache()
2 {
3+ // Only descriptor wallets can upgrade descriptor cache
4+ Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
5+
6- if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) || IsLocked() || IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) {
7+ if (IsLocked() || IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) {
8 return;
9 }