Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 523 Lines • ▼ Show 20 Lines | if (fRequireStandard && !IsStandardTx(tx, reason)) { | ||||
return state.DoS(0, false, REJECT_NONSTANDARD, reason); | return state.DoS(0, false, REJECT_NONSTANDARD, reason); | ||||
} | } | ||||
// Only accept nLockTime-using transactions that can be mined in the next | // Only accept nLockTime-using transactions that can be mined in the next | ||||
// block; we don't want our mempool filled up with transactions that can't | // block; we don't want our mempool filled up with transactions that can't | ||||
// be mined yet. | // be mined yet. | ||||
CValidationState ctxState; | CValidationState ctxState; | ||||
if (!ContextualCheckTransactionForCurrentBlock( | if (!ContextualCheckTransactionForCurrentBlock( | ||||
config, tx, ctxState, STANDARD_LOCKTIME_VERIFY_FLAGS)) { | consensusParams, tx, ctxState, STANDARD_LOCKTIME_VERIFY_FLAGS)) { | ||||
// We copy the state from a dummy to ensure we don't increase the | // We copy the state from a dummy to ensure we don't increase the | ||||
// ban score of peer for transaction that could be valid in the future. | // ban score of peer for transaction that could be valid in the future. | ||||
return state.DoS( | return state.DoS( | ||||
0, false, REJECT_NONSTANDARD, ctxState.GetRejectReason(), | 0, false, REJECT_NONSTANDARD, ctxState.GetRejectReason(), | ||||
ctxState.CorruptionPossible(), ctxState.GetDebugMessage()); | ctxState.CorruptionPossible(), ctxState.GetDebugMessage()); | ||||
} | } | ||||
// Is it already in the memory pool? | // Is it already in the memory pool? | ||||
▲ Show 20 Lines • Show All 3,099 Lines • ▼ Show 20 Lines | if ((block.nVersion < 2 && nHeight >= consensusParams.BIP34Height) || | ||||
false, REJECT_OBSOLETE, | false, REJECT_OBSOLETE, | ||||
strprintf("bad-version(0x%08x)", block.nVersion), | strprintf("bad-version(0x%08x)", block.nVersion), | ||||
strprintf("rejected nVersion=0x%08x block", block.nVersion)); | strprintf("rejected nVersion=0x%08x block", block.nVersion)); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool ContextualCheckTransactionForCurrentBlock(const Config &config, | bool ContextualCheckTransactionForCurrentBlock(const Consensus::Params ¶ms, | ||||
const CTransaction &tx, | const CTransaction &tx, | ||||
CValidationState &state, | CValidationState &state, | ||||
int flags) { | int flags) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
// By convention a negative value for flags indicates that the current | // By convention a negative value for flags indicates that the current | ||||
// network-enforced consensus rules should be used. In a future soft-fork | // network-enforced consensus rules should be used. In a future soft-fork | ||||
// scenario that would mean checking which rules would be enforced for the | // scenario that would mean checking which rules would be enforced for the | ||||
Show All 16 Lines | bool ContextualCheckTransactionForCurrentBlock(const Consensus::Params ¶ms, | ||||
// ContextualCheckTransaction() if LOCKTIME_MEDIAN_TIME_PAST is set. | // ContextualCheckTransaction() if LOCKTIME_MEDIAN_TIME_PAST is set. | ||||
const int64_t nMedianTimePast = | const int64_t nMedianTimePast = | ||||
chainActive.Tip() == nullptr ? 0 | chainActive.Tip() == nullptr ? 0 | ||||
: chainActive.Tip()->GetMedianTimePast(); | : chainActive.Tip()->GetMedianTimePast(); | ||||
const int64_t nLockTimeCutoff = (flags & LOCKTIME_MEDIAN_TIME_PAST) | const int64_t nLockTimeCutoff = (flags & LOCKTIME_MEDIAN_TIME_PAST) | ||||
? nMedianTimePast | ? nMedianTimePast | ||||
: GetAdjustedTime(); | : GetAdjustedTime(); | ||||
return ContextualCheckTransaction(config, tx, state, nBlockHeight, | return ContextualCheckTransaction(params, tx, state, nBlockHeight, | ||||
nLockTimeCutoff, nMedianTimePast); | nLockTimeCutoff, nMedianTimePast); | ||||
} | } | ||||
/** | /** | ||||
* NOTE: This function is not currently invoked by ConnectBlock(), so we | * NOTE: This function is not currently invoked by ConnectBlock(), so we | ||||
* should consider upgrade issues if we change which consensus rules are | * should consider upgrade issues if we change which consensus rules are | ||||
* enforced in this function (eg by adding a new consensus rule). See comment | * enforced in this function (eg by adding a new consensus rule). See comment | ||||
* in ConnectBlock(). | * in ConnectBlock(). | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | for (const auto &ptx : block.vtx) { | ||||
prevTx->GetId().ToString())); | prevTx->GetId().ToString())); | ||||
} | } | ||||
if (prevTx || !tx.IsCoinBase()) { | if (prevTx || !tx.IsCoinBase()) { | ||||
prevTx = &tx; | prevTx = &tx; | ||||
} | } | ||||
} | } | ||||
if (!ContextualCheckTransaction(config, tx, state, nHeight, | if (!ContextualCheckTransaction(consensusParams, tx, state, nHeight, | ||||
nLockTimeCutoff, nMedianTimePast)) { | nLockTimeCutoff, nMedianTimePast)) { | ||||
// state set by ContextualCheckTransaction. | // state set by ContextualCheckTransaction. | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// Enforce rule that the coinbase starts with serialized block height | // Enforce rule that the coinbase starts with serialized block height | ||||
if (nHeight >= consensusParams.BIP34Height) { | if (nHeight >= consensusParams.BIP34Height) { | ||||
▲ Show 20 Lines • Show All 1,955 Lines • Show Last 20 Lines |