GenerateNewKey must be guarded by a cs_wallet lock

This commit is contained in:
Kris Nuttycombe 2022-02-26 20:11:42 -07:00
parent 7d9dda4b7e
commit 399ffa7f5c
1 changed files with 2 additions and 0 deletions

View File

@ -5719,6 +5719,8 @@ bool CWallet::InitLoadWallet(const CChainParams& params, bool clearWitnessCaches
{
// Create new keyUser and set as default key
if (!walletInstance->IsCrypted()) {
LOCK(walletInstance->cs_wallet);
CPubKey newDefaultKey = walletInstance->GenerateNewKey(true);
walletInstance->SetDefaultKey(newDefaultKey);
if (!walletInstance->SetAddressBook(walletInstance->vchDefaultKey.GetID(), "", "receive"))