diff --git a/src/init.cpp b/src/init.cpp index f9da81e87..6910cf308 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6dfa15025..97500911a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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;