Skip to content

Commit 86071f9

Browse files
Merge dashpay#6772: fix: let upgradetohd work for encrypted Descriptor wallets same as legacy wallets
ae49943 refactor: drop unused includes from wallet.cpp (Konstantin Akimov) 10d9a67 fix: let upgradetohd work for encrypted Descriptor wallets same as legacy wallets (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented `upgradetohd` has 3rd argument 'passphrase' specially for encrypted wallet but it is ignored for Descriptor Wallet and wallet should be manually unlocked before call of `upgradetohd`. ## What was done? RPC `upgradetohd` actually works now with enctypred Descriptor Wallets without requirement to unlock them first. ## How Has This Been Tested? Tests to be merged in dashpay#6763 ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK ae49943 UdjinM6: utACK ae49943 Tree-SHA512: 8c342cb4f5c76689c8e6f9fc36fbc59e8cd9ada75065b2a9a43896171dab1f4c41a7dd3f8a8edcb1f9918bcff675dbecf45cd5df32306c704f45e362853ce168
2 parents d68bc28 + ae49943 commit 86071f9

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/wallet/wallet.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <chainparams.h>
1111
#include <consensus/amount.h>
1212
#include <consensus/consensus.h>
13-
#include <consensus/validation.h>
1413
#include <crypto/common.h>
1514
#include <fs.h>
1615
#include <interfaces/chain.h>
@@ -19,7 +18,6 @@
1918
#include <key_io.h>
2019
#include <policy/fees.h>
2120
#include <policy/policy.h>
22-
#include <policy/settings.h>
2321
#include <primitives/block.h>
2422
#include <primitives/transaction.h>
2523
#include <script/descriptor.h>
@@ -28,10 +26,8 @@
2826
#include <script/signingprovider.h>
2927
#include <support/cleanse.h>
3028
#include <txmempool.h>
31-
#include <util/bip32.h>
3229
#include <util/check.h>
3330
#include <util/error.h>
34-
#include <util/fees.h>
3531
#include <util/moneystr.h>
3632
#include <util/string.h>
3733
#include <util/translation.h>
@@ -40,11 +36,9 @@
4036
#endif
4137
#include <wallet/bip39.h> // TODO(refactor): move dependency it to scriptpubkeyman.cpp
4238
#include <wallet/coincontrol.h>
43-
#include <wallet/coinselection.h>
4439
#include <wallet/context.h>
4540
#include <warnings.h>
4641

47-
#include <coinjoin/common.h>
4842
#include <coinjoin/options.h>
4943
#include <evo/providertx.h>
5044
#include <governance/vote.h>
@@ -3228,7 +3222,24 @@ bool CWallet::UpgradeToHD(const SecureString& secureMnemonic, const SecureString
32283222
SetMinVersion(FEATURE_HD);
32293223

32303224
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+
}
32313237
SetupDescriptorScriptPubKeyMans(secureMnemonic, secureMnemonicPassphrase);
3238+
3239+
if (IsCrypted()) {
3240+
// Relock the wallet
3241+
Lock();
3242+
}
32323243
} else {
32333244
if (!GenerateNewHDChain(secureMnemonic, secureMnemonicPassphrase, secureWalletPassphrase)) {
32343245
error = Untranslated("Failed to generate HD wallet");

0 commit comments

Comments
 (0)