mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
fix: wallet should be unlocked before generating keys for Descriptor wallet
This commit is contained in:
parent
f293c046f4
commit
c1b94b6f52
@ -310,6 +310,14 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, interfaces::Coin
|
||||
return nullptr;
|
||||
}
|
||||
if (!create_blank) {
|
||||
// Unlock the wallet
|
||||
if (!wallet->Unlock(passphrase)) {
|
||||
error = Untranslated("Error: Wallet was encrypted but could not be unlocked");
|
||||
status = DatabaseStatus::FAILED_ENCRYPT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Set a seed for the wallet
|
||||
if (wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
LOCK(wallet->cs_wallet);
|
||||
wallet->SetupDescriptorScriptPubKeyMans();
|
||||
@ -325,13 +333,6 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, interfaces::Coin
|
||||
}
|
||||
}
|
||||
|
||||
// Unlock the wallet
|
||||
if (!wallet->Unlock(passphrase)) {
|
||||
error = Untranslated("Error: Wallet was encrypted but could not be unlocked");
|
||||
status = DatabaseStatus::FAILED_ENCRYPT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// backup the wallet we just encrypted
|
||||
if (!wallet->AutoBackupWallet("", error, warnings) && !error.original.empty()) {
|
||||
status = DatabaseStatus::FAILED_ENCRYPT;
|
||||
@ -4885,6 +4886,7 @@ bool CWallet::UpgradeToHD(const SecureString& secureMnemonic, const SecureString
|
||||
error = Untranslated("Failed to generate encrypted HD wallet");
|
||||
return false;
|
||||
}
|
||||
Lock();
|
||||
} else {
|
||||
spk_man->GenerateNewHDChain(secureMnemonic, secureMnemonicPassphrase);
|
||||
}
|
||||
@ -5505,7 +5507,6 @@ bool CWallet::GenerateNewHDChainEncrypted(const SecureString& secureMnemonic, co
|
||||
if (!spk_man->NewKeyPool()) {
|
||||
throw std::runtime_error(std::string(__func__) + ": NewKeyPool failed");
|
||||
}
|
||||
Lock();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user