From 2fbddf7474e95eff47fbf27175ab60c03e75b56c Mon Sep 17 00:00:00 2001 From: alex v Date: Mon, 18 Nov 2019 00:20:00 +0100 Subject: [PATCH] fix reference to chain tip --- src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3acd46781..e20f80947 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4474,21 +4474,12 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P return error("CheckBlock() : bad proof-of-stake block signature"); } - bool fColdStakingEnabled = IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus()); - // Check transactions for(const CTransaction& tx: block.vtx) { if (!CheckTransaction(tx, state)) return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), strprintf("Transaction check failed (tx hash %s) %s\n%s", tx.GetHash().ToString(), state.GetDebugMessage(), tx.ToString())); - - if (!fColdStakingEnabled) - { - for (const CTxOut& txout: tx.vout) - if(txout.scriptPubKey.IsColdStaking()) - return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled"); - } } unsigned int nSigOps = 0; @@ -4788,11 +4779,20 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn ? pindexPrev->GetMedianTimePast() : block.GetBlockTime(); - // Check that all transactions are finalized + bool fColdStakingEnabled = IsColdStakingEnabled(pindexPrev,Params().GetConsensus()); + + // Check that all transactions are finalized and no early cold stake for(const CTransaction& tx: block.vtx) { if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction"); } + + if (!fColdStakingEnabled) + { + for (const CTxOut& txout: tx.vout) + if(txout.scriptPubKey.IsColdStaking()) + return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled"); + } } // Enforce block.nVersion=2 rule that the coinbase starts with serialized block height