Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 513 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
// Validate input scripts against standard script flags. | // Validate input scripts against standard script flags. | ||||
const uint32_t scriptVerifyFlags = | const uint32_t scriptVerifyFlags = | ||||
nextBlockScriptVerifyFlags | STANDARD_SCRIPT_VERIFY_FLAGS; | nextBlockScriptVerifyFlags | STANDARD_SCRIPT_VERIFY_FLAGS; | ||||
PrecomputedTransactionData txdata(tx); | PrecomputedTransactionData txdata(tx); | ||||
int nSigChecksStandard; | int nSigChecksStandard; | ||||
if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true, false, | if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true, false, | ||||
txdata, nSigChecksStandard)) { | txdata, nSigChecksStandard)) { | ||||
// State filled in by CheckInputs. | // State filled in by CheckInputs. | ||||
assert(IsTransactionReason(state.GetReason())); | |||||
return false; | return false; | ||||
} | } | ||||
CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, ::ChainActive().Height(), | CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, ::ChainActive().Height(), | ||||
fSpendsCoinbase, nSigChecksStandard, lp); | fSpendsCoinbase, nSigChecksStandard, lp); | ||||
unsigned int nVirtualSize = entry.GetTxVirtualSize(); | unsigned int nVirtualSize = entry.GetTxVirtualSize(); | ||||
▲ Show 20 Lines • Show All 1,173 Lines • ▼ Show 20 Lines | for (const auto &ptx : block.vtx) { | ||||
ValidationInvalidReason::TX_MISSING_INPUTS) { | ValidationInvalidReason::TX_MISSING_INPUTS) { | ||||
// CheckTxInputs may return MISSING_INPUTS but we can't return | // CheckTxInputs may return MISSING_INPUTS but we can't return | ||||
// that, as it's not defined for a block, so we reset the reason | // that, as it's not defined for a block, so we reset the reason | ||||
// flag to CONSENSUS here. | // flag to CONSENSUS here. | ||||
state.Invalid(ValidationInvalidReason::CONSENSUS, false, | state.Invalid(ValidationInvalidReason::CONSENSUS, false, | ||||
state.GetRejectCode(), state.GetRejectReason(), | state.GetRejectCode(), state.GetRejectReason(), | ||||
state.GetDebugMessage()); | state.GetDebugMessage()); | ||||
} | } | ||||
assert(IsBlockReason(state.GetReason())); | |||||
return error("%s: Consensus::CheckTxInputs: %s, %s", __func__, | return error("%s: Consensus::CheckTxInputs: %s, %s", __func__, | ||||
tx.GetId().ToString(), FormatStateMessage(state)); | tx.GetId().ToString(), FormatStateMessage(state)); | ||||
} | } | ||||
nFees += txfee; | nFees += txfee; | ||||
if (!MoneyRange(nFees)) { | if (!MoneyRange(nFees)) { | ||||
return state.Invalid( | return state.Invalid( | ||||
ValidationInvalidReason::CONSENSUS, | ValidationInvalidReason::CONSENSUS, | ||||
error("%s: accumulated fee in the block out of range.", | error("%s: accumulated fee in the block out of range.", | ||||
▲ Show 20 Lines • Show All 2,279 Lines • ▼ Show 20 Lines | bool CChainState::AcceptBlock(const Config &config, | ||||
} | } | ||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
const Consensus::Params &consensusParams = chainparams.GetConsensus(); | const Consensus::Params &consensusParams = chainparams.GetConsensus(); | ||||
if (!CheckBlock(block, state, consensusParams, | if (!CheckBlock(block, state, consensusParams, | ||||
BlockValidationOptions(config)) || | BlockValidationOptions(config)) || | ||||
!ContextualCheckBlock(block, state, consensusParams, pindex->pprev)) { | !ContextualCheckBlock(block, state, consensusParams, pindex->pprev)) { | ||||
assert(IsBlockReason(state.GetReason())); | |||||
if (state.IsInvalid() && | if (state.IsInvalid() && | ||||
state.GetReason() != ValidationInvalidReason::BLOCK_MUTATED) { | state.GetReason() != ValidationInvalidReason::BLOCK_MUTATED) { | ||||
pindex->nStatus = pindex->nStatus.withFailed(); | pindex->nStatus = pindex->nStatus.withFailed(); | ||||
setDirtyBlockIndex.insert(pindex); | setDirtyBlockIndex.insert(pindex); | ||||
} | } | ||||
return error("%s: %s (block %s)", __func__, FormatStateMessage(state), | return error("%s: %s (block %s)", __func__, FormatStateMessage(state), | ||||
block.GetHash().ToString()); | block.GetHash().ToString()); | ||||
▲ Show 20 Lines • Show All 1,640 Lines • Show Last 20 Lines |