|
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>
|
|
40 | 36 | #endif
|
41 | 37 | #include <wallet/bip39.h> // TODO(refactor): move dependency it to scriptpubkeyman.cpp
|
42 | 38 | #include <wallet/coincontrol.h>
|
43 |
| -#include <wallet/coinselection.h> |
44 | 39 | #include <wallet/context.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>
|
@@ -3228,7 +3222,24 @@ bool CWallet::UpgradeToHD(const SecureString& secureMnemonic, const SecureString
|
3228 | 3222 | SetMinVersion(FEATURE_HD);
|
3229 | 3223 |
|
3230 | 3224 | if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
| 3225 | + if (IsCrypted()) { |
| 3226 | + if (secureWalletPassphrase.empty()) { |
| 3227 | + error = Untranslated("Error: Wallet encrypted but supplied empty wallet passphrase"); |
| 3228 | + return false; |
| 3229 | + } |
| 3230 | + |
| 3231 | + // Unlock the wallet |
| 3232 | + if (!Unlock(secureWalletPassphrase)) { |
| 3233 | + error = Untranslated("Error: The wallet passphrase entered was incorrect"); |
| 3234 | + return false; |
| 3235 | + } |
| 3236 | + } |
3231 | 3237 | SetupDescriptorScriptPubKeyMans(secureMnemonic, secureMnemonicPassphrase);
|
| 3238 | + |
| 3239 | + if (IsCrypted()) { |
| 3240 | + // Relock the wallet |
| 3241 | + Lock(); |
| 3242 | + } |
3232 | 3243 | } else {
|
3233 | 3244 | if (!GenerateNewHDChain(secureMnemonic, secureMnemonicPassphrase, secureWalletPassphrase)) {
|
3234 | 3245 | error = Untranslated("Failed to generate HD wallet");
|
|
0 commit comments