Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reference to chain tip #632

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down