Skip to content

Commit 3bd8db8

Browse files
committed
[validation] fix comments in CheckInputScripts()
1 parent 6f6465c commit 3bd8db8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/validation.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
406406
for (const CTxIn& txin : tx.vin) {
407407
const Coin& coin = view.AccessCoin(txin.prevout);
408408

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

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

910910
constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
911911

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

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

0 commit comments

Comments
 (0)