Skip to content

Commit 2ad3391

Browse files
authored
Merge pull request #632 from aguycalled/early-coldstake-check
Fix reference to chain tip
2 parents 2a6c64f + ab2c02c commit 2ad3391

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,21 +4530,12 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
45304530
return error("CheckBlock() : bad proof-of-stake block signature");
45314531
}
45324532

4533-
bool fColdStakingEnabled = IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus());
4534-
45354533
// Check transactions
45364534
for(const CTransaction& tx: block.vtx)
45374535
{
45384536
if (!CheckTransaction(tx, state))
45394537
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
45404538
strprintf("Transaction check failed (tx hash %s) %s\n%s", tx.GetHash().ToString(), state.GetDebugMessage(), tx.ToString()));
4541-
4542-
if (!fColdStakingEnabled)
4543-
{
4544-
for (const CTxOut& txout: tx.vout)
4545-
if(txout.scriptPubKey.IsColdStaking())
4546-
return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled");
4547-
}
45484539
}
45494540

45504541
unsigned int nSigOps = 0;
@@ -4844,11 +4835,20 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
48444835
? pindexPrev->GetMedianTimePast()
48454836
: block.GetBlockTime();
48464837

4847-
// Check that all transactions are finalized
4838+
bool fColdStakingEnabled = IsColdStakingEnabled(pindexPrev,Params().GetConsensus());
4839+
4840+
// Check that all transactions are finalized and no early cold stake
48484841
for(const CTransaction& tx: block.vtx) {
48494842
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) {
48504843
return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction");
48514844
}
4845+
4846+
if (!fColdStakingEnabled)
4847+
{
4848+
for (const CTxOut& txout: tx.vout)
4849+
if(txout.scriptPubKey.IsColdStaking())
4850+
return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled");
4851+
}
48524852
}
48534853

48544854
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height

0 commit comments

Comments
 (0)