From 10d9a67ea319011cbfabf497528bf7c50c7d66c1 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 18 Jul 2025 15:57:01 +0700 Subject: [PATCH 1/2] fix: let upgradetohd work for encrypted Descriptor wallets same as legacy wallets --- src/wallet/wallet.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6979c5d49fae..c6e95cc683a0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3228,7 +3228,24 @@ bool CWallet::UpgradeToHD(const SecureString& secureMnemonic, const SecureString SetMinVersion(FEATURE_HD); if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { + if (IsCrypted()) { + if (secureWalletPassphrase.empty()) { + error = Untranslated("Error: Wallet encrypted but supplied empty wallet passphrase"); + return false; + } + + // Unlock the wallet + if (!Unlock(secureWalletPassphrase)) { + error = Untranslated("Error: The wallet passphrase entered was incorrect"); + return false; + } + } SetupDescriptorScriptPubKeyMans(secureMnemonic, secureMnemonicPassphrase); + + if (IsCrypted()) { + // Relock the wallet + Lock(); + } } else { if (!GenerateNewHDChain(secureMnemonic, secureMnemonicPassphrase, secureWalletPassphrase)) { error = Untranslated("Failed to generate HD wallet"); From ae4994387c238b99a058a04f360675bb59483ade Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Sat, 19 Jul 2025 18:21:39 +0700 Subject: [PATCH 2/2] refactor: drop unused includes from wallet.cpp --- src/wallet/wallet.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c6e95cc683a0..8055410d57f6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,6 @@ #include #include #include -#include #include #include #include