init: Fix new HD seed generation for previously-encrypted wallets
Closes #3607.
This commit is contained in:
parent
a8d4a2216d
commit
1f561f323f
|
@ -1645,8 +1645,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
|
||||
if (!pwalletMain->HaveHDSeed())
|
||||
{
|
||||
// generate a new HD seed
|
||||
pwalletMain->GenerateNewSeed();
|
||||
// We can't set the new HD seed until the wallet is decrypted.
|
||||
// https://github.com/zcash/zcash/issues/3607
|
||||
if (!pwalletMain->IsCrypted()) {
|
||||
// generate a new HD seed
|
||||
pwalletMain->GenerateNewSeed();
|
||||
}
|
||||
}
|
||||
|
||||
if (fFirstRun)
|
||||
|
|
|
@ -499,8 +499,14 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase)
|
|||
return false;
|
||||
if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey))
|
||||
continue; // try another master key
|
||||
if (CCryptoKeyStore::Unlock(vMasterKey))
|
||||
if (CCryptoKeyStore::Unlock(vMasterKey)) {
|
||||
// Now that the wallet is decrypted, ensure we have an HD seed.
|
||||
// https://github.com/zcash/zcash/issues/3607
|
||||
if (!this->HaveHDSeed()) {
|
||||
this->GenerateNewSeed();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue