From 399ffa7f5c811720d3c4fd61b08bad4a33eaf838 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Sat, 26 Feb 2022 20:11:42 -0700 Subject: [PATCH] GenerateNewKey must be guarded by a cs_wallet lock --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 03a3bd81b..f9be3a9d5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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"))