More of 11634: wallet: Add missing cs_wallet/cs_KeyStore locks to wallet

This commit is contained in:
UdjinM6 2021-07-29 04:19:14 +03:00
parent 21b98ba189
commit 25f5611d1a
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9
3 changed files with 11 additions and 3 deletions

View File

@ -58,11 +58,12 @@ public:
CWalletTx& AddTxToChain(uint256 nTxHash)
{
auto it = wallet->mapWallet.find(nTxHash);
assert(it != wallet->mapWallet.end());
std::map<uint256, CWalletTx>::iterator it;
CMutableTransaction blocktx;
{
LOCK(wallet->cs_wallet);
it = wallet->mapWallet.find(nTxHash);
assert(it != wallet->mapWallet.end());
blocktx = CMutableTransaction(*it->second.tx);
}
CreateAndProcessBlock({blocktx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));

View File

@ -1043,6 +1043,8 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
bool CWallet::GetLabelDestination(CTxDestination &dest, const std::string& label, bool bForceNew)
{
AssertLockHeld(cs_wallet);
WalletBatch batch(*database);
CAccount account;
@ -2474,6 +2476,8 @@ CAmount CWalletTx::GetAnonymizedCredit(const CCoinControl* coinControl) const
if (!pwallet)
return 0;
AssertLockHeld(pwallet->cs_wallet);
// Exclude coinbase and conflicted txes
if (IsCoinBase() || GetDepthInMainChain() < 0)
return 0;
@ -2514,6 +2518,8 @@ CAmount CWalletTx::GetDenominatedCredit(bool unconfirmed, bool fUseCache) const
if (pwallet == nullptr)
return 0;
AssertLockHeld(pwallet->cs_wallet);
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
@ -3725,6 +3731,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
}
auto calculateFee = [&](CAmount& nFee) -> bool {
AssertLockHeld(cs_wallet);
nBytes = CalculateMaximumSignedTxSize(txNew, this, coin_control.fAllowWatchOnly);
if (nBytes < 0) {
strFailReason = _("Signing transaction failed");

View File

@ -785,7 +785,7 @@ private:
/* HD derive new child key (on internal or external chain) */
void DeriveNewChildKey(WalletBatch &batch, const CKeyMetadata& metadata, CKey& secretRet, uint32_t nAccountIndex, bool fInternal /*= false*/) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
std::set<int64_t> setInternalKeyPool;
std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_wallet);
std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_wallet);
int64_t m_max_keypool_index GUARDED_BY(cs_wallet) = 0;
std::map<CKeyID, int64_t> m_pool_key_to_index;