diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -803,7 +803,7 @@ //! the current wallet version: clients below this version are not able to //! load the wallet - int nWalletVersion = FEATURE_BASE; + int nWalletVersion GUARDED_BY(cs_wallet) = FEATURE_BASE; //! the maximum wallet format version: memory-only variable that specifies //! to what version this wallet may be upgraded @@ -880,9 +880,9 @@ CKey &secret, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - std::set setInternalKeyPool; + std::set setInternalKeyPool GUARDED_BY(cs_wallet); std::set setExternalKeyPool GUARDED_BY(cs_wallet); - std::set set_pre_split_keypool; + std::set set_pre_split_keypool GUARDED_BY(cs_wallet); int64_t m_max_keypool_index GUARDED_BY(cs_wallet) = 0; std::map m_pool_key_to_index; std::atomic m_wallet_flags{0}; @@ -1444,7 +1444,6 @@ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { - // set{Ex,In}ternalKeyPool AssertLockHeld(cs_wallet); return setInternalKeyPool.size() + setExternalKeyPool.size(); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -280,7 +280,6 @@ CPubKey CWallet::GenerateNewKey(WalletBatch &batch, bool internal) { assert(!IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); assert(!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)); - // mapKeyMetadata AssertLockHeld(cs_wallet); // default to compressed public keys if we want 0.6.0 wallets bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); @@ -395,7 +394,6 @@ bool CWallet::AddKeyPubKeyWithDB(WalletBatch &batch, const CKey &secret, const CPubKey &pubkey) { - // mapKeyMetadata AssertLockHeld(cs_wallet); // Make sure we aren't adding private keys to private key disabled wallets @@ -462,7 +460,6 @@ } void CWallet::LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &meta) { - // mapKeyMetadata AssertLockHeld(cs_wallet); UpdateTimeFirstKey(meta.nCreateTime); mapKeyMetadata[keyID] = meta; @@ -470,14 +467,12 @@ void CWallet::LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &meta) { - // m_script_metadata AssertLockHeld(cs_wallet); UpdateTimeFirstKey(meta.nCreateTime); m_script_metadata[script_id] = meta; } void CWallet::UpgradeKeyMetadata() { - // mapKeyMetadata AssertLockHeld(cs_wallet); if (IsLocked() || IsWalletFlagSet(WALLET_FLAG_KEY_ORIGIN_METADATA)) { return; @@ -769,7 +764,6 @@ void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch *batch_in, bool fExplicit) { - // nWalletVersion LOCK(cs_wallet); if (nWalletVersion >= nVersion) { return; @@ -797,7 +791,6 @@ } bool CWallet::SetMaxVersion(int nVersion) { - // nWalletVersion, nWalletMaxVersion LOCK(cs_wallet); // Cannot downgrade below current version @@ -1108,7 +1101,6 @@ } int64_t CWallet::IncOrderPosNext(WalletBatch *batch) { - // nOrderPosNext AssertLockHeld(cs_wallet); int64_t nRet = nOrderPosNext++; if (batch) { @@ -3088,6 +3080,7 @@ } bool CWallet::SignTransaction(CMutableTransaction &tx) { + AssertLockHeld(cs_wallet); // sign the new tx int nIn = 0; for (CTxIn &input : tx.vin) { @@ -3721,7 +3714,6 @@ DBErrors CWallet::ZapSelectTx(std::vector &txIdsIn, std::vector &txIdsOut) { - // mapWallet AssertLockHeld(cs_wallet); DBErrors nZapSelectTxRet = WalletBatch(*database, "cr+").ZapSelectTx(txIdsIn, txIdsOut); @@ -3877,7 +3869,6 @@ } size_t CWallet::KeypoolCountExternalKeys() { - // setExternalKeyPool AssertLockHeld(cs_wallet); return setExternalKeyPool.size() + set_pre_split_keypool.size(); } @@ -4199,7 +4190,6 @@ } std::set> CWallet::GetAddressGroupings() { - // mapWallet AssertLockHeld(cs_wallet); std::set> groupings; std::set grouping; @@ -4397,32 +4387,27 @@ } void CWallet::LockCoin(const COutPoint &output) { - // setLockedCoins AssertLockHeld(cs_wallet); setLockedCoins.insert(output); } void CWallet::UnlockCoin(const COutPoint &output) { - // setLockedCoins AssertLockHeld(cs_wallet); setLockedCoins.erase(output); } void CWallet::UnlockAllCoins() { - // setLockedCoins AssertLockHeld(cs_wallet); setLockedCoins.clear(); } bool CWallet::IsLockedCoin(const COutPoint &outpoint) const { - // setLockedCoins AssertLockHeld(cs_wallet); return setLockedCoins.count(outpoint) > 0; } void CWallet::ListLockedCoins(std::vector &vOutpts) const { - // setLockedCoins AssertLockHeld(cs_wallet); for (COutPoint outpoint : setLockedCoins) { vOutpts.push_back(outpoint); @@ -4433,7 +4418,6 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock &locked_chain, std::map &mapKeyBirth) const { - // mapKeyMetadata AssertLockHeld(cs_wallet); mapKeyBirth.clear(); @@ -4762,7 +4746,7 @@ } } - int prev_version = walletInstance->nWalletVersion; + int prev_version = walletInstance->GetVersion(); if (gArgs.GetBoolArg("-upgradewallet", fFirstRun)) { int nMaxVersion = gArgs.GetArg("-upgradewallet", 0); // The -upgradewallet without argument case @@ -4791,7 +4775,7 @@ // Do not upgrade versions to any version between HD_SPLIT and // FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT - int max_version = walletInstance->nWalletVersion; + int max_version = walletInstance->GetVersion(); if (!walletInstance->CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {