init: Fix new HD seed generation for previously-encrypted wallets

Closes #3607.
This commit is contained in:
Jack Grigg 2019-04-04 18:27:46 +01:00
parent a8d4a2216d
commit 1f561f323f
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
2 changed files with 13 additions and 3 deletions

View File

@ -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)

View File

@ -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;