|
10 | 10 | #include <chainparams.h> |
11 | 11 | #include <consensus/amount.h> |
12 | 12 | #include <consensus/consensus.h> |
13 | | -#include <consensus/validation.h> |
14 | 13 | #include <crypto/common.h> |
15 | 14 | #include <fs.h> |
16 | 15 | #include <interfaces/chain.h> |
|
19 | 18 | #include <key_io.h> |
20 | 19 | #include <policy/fees.h> |
21 | 20 | #include <policy/policy.h> |
22 | | -#include <policy/settings.h> |
23 | 21 | #include <primitives/block.h> |
24 | 22 | #include <primitives/transaction.h> |
25 | 23 | #include <script/descriptor.h> |
|
28 | 26 | #include <script/signingprovider.h> |
29 | 27 | #include <support/cleanse.h> |
30 | 28 | #include <txmempool.h> |
31 | | -#include <util/bip32.h> |
32 | 29 | #include <util/check.h> |
33 | 30 | #include <util/error.h> |
34 | | -#include <util/fees.h> |
35 | 31 | #include <util/moneystr.h> |
36 | 32 | #include <util/string.h> |
37 | 33 | #include <util/translation.h> |
|
41 | 37 | #include <wallet/bip39.h> // TODO(refactor): move dependency it to scriptpubkeyman.cpp |
42 | 38 | #include <wallet/coincontrol.h> |
43 | 39 | #include <wallet/coinselection.h> |
44 | | -#include <wallet/fees.h> |
45 | 40 | #include <warnings.h> |
46 | 41 |
|
47 | | -#include <coinjoin/common.h> |
48 | 42 | #include <coinjoin/options.h> |
49 | 43 | #include <evo/providertx.h> |
50 | 44 | #include <governance/vote.h> |
@@ -5201,7 +5195,24 @@ bool CWallet::UpgradeToHD(const SecureString& secureMnemonic, const SecureString |
5201 | 5195 | SetMinVersion(FEATURE_HD); |
5202 | 5196 |
|
5203 | 5197 | if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { |
| 5198 | + if (IsCrypted()) { |
| 5199 | + if (secureWalletPassphrase.empty()) { |
| 5200 | + error = Untranslated("Error: Wallet encrypted but supplied empty wallet passphrase"); |
| 5201 | + return false; |
| 5202 | + } |
| 5203 | + |
| 5204 | + // Unlock the wallet |
| 5205 | + if (!Unlock(secureWalletPassphrase)) { |
| 5206 | + error = Untranslated("Error: The wallet passphrase entered was incorrect"); |
| 5207 | + return false; |
| 5208 | + } |
| 5209 | + } |
5204 | 5210 | SetupDescriptorScriptPubKeyMans(secureMnemonic, secureMnemonicPassphrase); |
| 5211 | + |
| 5212 | + if (IsCrypted()) { |
| 5213 | + // Relock the wallet |
| 5214 | + Lock(); |
| 5215 | + } |
5205 | 5216 | } else { |
5206 | 5217 | if (!GenerateNewHDChain(secureMnemonic, secureMnemonicPassphrase, secureWalletPassphrase)) { |
5207 | 5218 | error = Untranslated("Failed to generate HD wallet"); |
|
0 commit comments