Skip to content

Commit de6e167

Browse files
authored
Merge pull request #506 from aguycalled/fix-deadlock
Fix potential deadlock
2 parents e061768 + 32a2095 commit de6e167

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,6 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
11861186
nValueOut += txout.nValue;
11871187
if (!MoneyRange(nValueOut))
11881188
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
1189-
if(txout.scriptPubKey.IsColdStaking() && !IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus()))
1190-
return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled");
11911189
}
11921190

11931191
// Check for duplicate inputs
@@ -1377,6 +1375,15 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
13771375

13781376
nValueIn = view.GetValueIn(tx);
13791377

1378+
if (!IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus()))
1379+
{
1380+
for (const CTxOut& txout: tx.vout)
1381+
{
1382+
if(txout.scriptPubKey.IsColdStaking())
1383+
return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled");
1384+
}
1385+
}
1386+
13801387
if(IsCommunityFundEnabled(chainActive.Tip(), Params().GetConsensus())) {
13811388
CAmount nProposalFee = 0;
13821389
bool fReducedQuorum = IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus());
@@ -4454,12 +4461,23 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
44544461
return error("CheckBlock() : bad proof-of-stake block signature");
44554462
}
44564463

4464+
bool fColdStakingEnabled = IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus());
4465+
44574466
// Check transactions
44584467
BOOST_FOREACH(const CTransaction& tx, block.vtx)
4468+
{
44594469
if (!CheckTransaction(tx, state))
44604470
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
44614471
strprintf("Transaction check failed (tx hash %s) %s\n%s", tx.GetHash().ToString(), state.GetDebugMessage(), tx.ToString()));
44624472

4473+
if (!fColdStakingEnabled)
4474+
{
4475+
for (const CTxOut& txout: tx.vout)
4476+
if(txout.scriptPubKey.IsColdStaking())
4477+
return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled");
4478+
}
4479+
}
4480+
44634481
unsigned int nSigOps = 0;
44644482
BOOST_FOREACH(const CTransaction& tx, block.vtx)
44654483
nSigOps += GetLegacySigOpCount(tx);

0 commit comments

Comments
 (0)