Skip to content

Commit

Permalink
[validation] fix comments in CheckInputScripts()
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewbery committed Nov 7, 2019
1 parent 6f6465c commit 3bd8db8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,12 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
for (const CTxIn& txin : tx.vin) {
const Coin& coin = view.AccessCoin(txin.prevout);

// At this point we haven't actually checked if the coins are all
// available (or shouldn't assume we have, since CheckInputScripts does).
// So we just return failure if the inputs are not available here,
// and then only have to check equivalence for available inputs.
// AcceptToMemoryPoolWorker has already checked that the coins are
// available, so this shouldn't fail. If the inputs are not available
// here then return false.
if (coin.IsSpent()) return false;

// Check equivalence for available inputs.
const CTransactionRef& txFrom = pool.get(txin.prevout.hash);
if (txFrom) {
assert(txFrom->GetHash() == txin.prevout.hash);
Expand Down Expand Up @@ -909,7 +909,7 @@ bool MemPoolAccept::PolicyScriptChecks(ATMPArgs& args, Workspace& ws, Precompute

constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;

// Check against previous transactions
// Check input scripts and signatures.
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
if (!CheckInputScripts(tx, state, m_view, scriptVerifyFlags, true, false, txdata)) {
// SCRIPT_VERIFY_CLEANSTACK requires SCRIPT_VERIFY_WITNESS, so we
Expand Down Expand Up @@ -1469,8 +1469,10 @@ void InitScriptExecutionCache() {
}

/**
* Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts)
* This does not modify the UTXO set.
* Check whether all of this transaction's input scripts succeed.
*
* This involves ECDSA signature checks so can be computationally intensive. This function should
* only be called after the cheap sanity checks in CheckTxInputs passed.
*
* If pvChecks is not nullptr, script checks are pushed onto it instead of being performed inline. Any
* script checks which are not necessary (eg due to script execution cache hits) are, obviously,
Expand Down

0 comments on commit 3bd8db8

Please sign in to comment.