Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,141 Lines • ▼ Show 20 Lines | |||||
bool CheckInputs(const CTransaction &tx, CValidationState &state, | bool CheckInputs(const CTransaction &tx, CValidationState &state, | ||||
const CCoinsViewCache &inputs, bool fScriptChecks, | const CCoinsViewCache &inputs, bool fScriptChecks, | ||||
const uint32_t flags, bool sigCacheStore, | const uint32_t flags, bool sigCacheStore, | ||||
bool scriptCacheStore, | bool scriptCacheStore, | ||||
const PrecomputedTransactionData &txdata, | const PrecomputedTransactionData &txdata, | ||||
std::vector<CScriptCheck> *pvChecks) { | std::vector<CScriptCheck> *pvChecks) { | ||||
assert(!tx.IsCoinBase()); | assert(!tx.IsCoinBase()); | ||||
// This call does all the inexpensive checks on all the inputs. Only if ALL | |||||
// inputs pass do we perform expensive ECDSA signature checks. Helps prevent | |||||
// CPU exhaustion attacks. | |||||
if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs))) { | if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs))) { | ||||
return false; | return false; | ||||
} | } | ||||
if (pvChecks) { | if (pvChecks) { | ||||
pvChecks->reserve(tx.vin.size()); | pvChecks->reserve(tx.vin.size()); | ||||
} | } | ||||
// The first loop above does all the inexpensive checks. Only if ALL inputs | |||||
// pass do we perform expensive ECDSA signature checks. Helps prevent CPU | |||||
// exhaustion attacks. | |||||
// Skip script verification when connecting blocks under the assumedvalid | // Skip script verification when connecting blocks under the assumedvalid | ||||
// block. Assuming the assumedvalid block is valid this is safe because | // block. Assuming the assumedvalid block is valid this is safe because | ||||
// block merkle hashes are still computed and checked, of course, if an | // block merkle hashes are still computed and checked, of course, if an | ||||
// assumed valid block is invalid due to false scriptSigs this optimization | // assumed valid block is invalid due to false scriptSigs this optimization | ||||
// would allow an invalid chain to be accepted. | // would allow an invalid chain to be accepted. | ||||
if (!fScriptChecks) { | if (!fScriptChecks) { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,413 Lines • Show Last 20 Lines |