From 4c5491f99c6b8ca779c48be63eb2ba18d98ee52a Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 7 Oct 2019 14:11:34 -0400 Subject: [PATCH] Refactor: Move SetWalletFlag out of LegacyScriptPubKeyMan::UpgradeKeyMetadata This commit does not change behavior. --- src/wallet/scriptpubkeyman.cpp | 2 -- src/wallet/wallet.cpp | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 03a7b8f289..df03f5c887 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -320,8 +320,6 @@ void LegacyScriptPubKeyMan::UpgradeKeyMetadata() } } } - batch.reset(); //write before setting the flag - m_storage.SetWalletFlag(WALLET_FLAG_KEY_ORIGIN_METADATA); } bool LegacyScriptPubKeyMan::IsHDEnabled() const diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2f1de5220b..7af2de224f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -249,10 +249,15 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const void CWallet::UpgradeKeyMetadata() { + if (IsLocked() || IsWalletFlagSet(WALLET_FLAG_KEY_ORIGIN_METADATA)) { + return; + } + if (m_spk_man) { AssertLockHeld(m_spk_man->cs_wallet); m_spk_man->UpgradeKeyMetadata(); } + SetWalletFlag(WALLET_FLAG_KEY_ORIGIN_METADATA); } bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys)