From 69f588a99a7a79d1d72300bc0f2c8475f95f6c6a Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 13 May 2025 14:33:45 -0700 Subject: [PATCH] wallet: Set upgraded descriptor cache flag for newly created wallets Although WalletBatch::LoadWallet performs the descriptor cache upgrade, because new wallets do not have the descriptor flag set yet, the upgrade does not run and set the flag. Since new wallets will always being using the upgraded cache, there's no reason to wait to set the flag, so set it when the wallet flags are being initialized for new wallets. --- src/wallet/wallet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4a4aa837eaa..75d34e7215e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2904,7 +2904,9 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri // ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key walletInstance->SetMinVersion(FEATURE_LATEST); - walletInstance->InitWalletFlags(wallet_creation_flags); + // Init with passed flags. + // Always set the cache upgrade flag as this feature is supported from the beginning. + walletInstance->InitWalletFlags(wallet_creation_flags | WALLET_FLAG_LAST_HARDENED_XPUB_CACHED); // Only descriptor wallets can be created assert(walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));