Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | static bool IsReplayProtectionEnabled(const Consensus::Params ¶ms, | ||||
const CBlockIndex *pindexPrev) { | const CBlockIndex *pindexPrev) { | ||||
if (pindexPrev == nullptr) { | if (pindexPrev == nullptr) { | ||||
return false; | return false; | ||||
} | } | ||||
return IsReplayProtectionEnabled(params, pindexPrev->GetMedianTimePast()); | return IsReplayProtectionEnabled(params, pindexPrev->GetMedianTimePast()); | ||||
} | } | ||||
// Returns the script flags which should be checked for mempool admission when | |||||
// the tip is at the given block. | |||||
static uint32_t GetStandardScriptFlags(const Consensus::Params ¶ms, | |||||
const CBlockIndex *pindexTip) { | |||||
// Use the consensus flags for the next block as a basis, and mix in the | |||||
// declared-standard flags. | |||||
uint32_t flags = GetNextBlockScriptFlags(params, pindexTip) | | |||||
STANDARD_SCRIPT_VERIFY_FLAGS; | |||||
// Disable input sigchecks limit for mempool admission, prior to its | |||||
// proper activation. | |||||
flags &= ~SCRIPT_VERIFY_INPUT_SIGCHECKS; | |||||
if (IsPhononEnabled(params, pindexTip)) { | |||||
flags |= SCRIPT_VERIFY_INPUT_SIGCHECKS; | |||||
} | |||||
return flags; | |||||
} | |||||
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool | // Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool | ||||
// were somehow broken and returning the wrong scriptPubKeys | // were somehow broken and returning the wrong scriptPubKeys | ||||
static bool CheckInputsFromMempoolAndCache( | static bool CheckInputsFromMempoolAndCache( | ||||
const CTransaction &tx, CValidationState &state, | const CTransaction &tx, CValidationState &state, | ||||
const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, | const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, | ||||
bool cacheSigStore, PrecomputedTransactionData &txdata, int &nSigChecksOut) | bool cacheSigStore, PrecomputedTransactionData &txdata, int &nSigChecksOut) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
if (nAbsurdFee != Amount::zero() && nFees > nAbsurdFee) { | if (nAbsurdFee != Amount::zero() && nFees > nAbsurdFee) { | ||||
return state.Invalid(false, REJECT_HIGHFEE, "absurdly-high-fee", | return state.Invalid(false, REJECT_HIGHFEE, "absurdly-high-fee", | ||||
strprintf("%d > %d", nFees, nAbsurdFee)); | strprintf("%d > %d", nFees, nAbsurdFee)); | ||||
} | } | ||||
// Validate input scripts against standard script flags. | // Validate input scripts against standard script flags. | ||||
const uint32_t scriptVerifyFlags = | const uint32_t scriptVerifyFlags = | ||||
GetStandardScriptFlags(consensusParams, ::ChainActive().Tip()); | 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. | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,099 Lines • Show Last 20 Lines |