Skip to content

Commit

Permalink
Merge pull request navcoin#632 from aguycalled/early-coldstake-check
Browse files Browse the repository at this point in the history
Fix reference to chain tip
  • Loading branch information
mxaddict committed Nov 22, 2019
2 parents f55c6b8 + 2fbddf7 commit a6c2a0f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4530,21 +4530,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;
Expand Down Expand Up @@ -4844,11 +4835,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
Expand Down

0 comments on commit a6c2a0f

Please sign in to comment.