init: Fix new HD seed generation for previously-encrypted wallets
Closes #3607.
This commit is contained in:
parent
a8d4a2216d
commit
1f561f323f
|
@ -1645,9 +1645,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
|
|
||||||
if (!pwalletMain->HaveHDSeed())
|
if (!pwalletMain->HaveHDSeed())
|
||||||
{
|
{
|
||||||
|
// 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
|
// generate a new HD seed
|
||||||
pwalletMain->GenerateNewSeed();
|
pwalletMain->GenerateNewSeed();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fFirstRun)
|
if (fFirstRun)
|
||||||
{
|
{
|
||||||
|
|
|
@ -499,10 +499,16 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase)
|
||||||
return false;
|
return false;
|
||||||
if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey))
|
if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey))
|
||||||
continue; // try another master key
|
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 true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue