@@ -406,12 +406,12 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
406
406
for (const CTxIn& txin : tx.vin ) {
407
407
const Coin& coin = view.AccessCoin (txin.prevout );
408
408
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.
413
412
if (coin.IsSpent ()) return false ;
414
413
414
+ // Check equivalence for available inputs.
415
415
const CTransactionRef& txFrom = pool.get (txin.prevout .hash );
416
416
if (txFrom) {
417
417
assert (txFrom->GetHash () == txin.prevout .hash );
@@ -909,7 +909,7 @@ bool MemPoolAccept::PolicyScriptChecks(ATMPArgs& args, Workspace& ws, Precompute
909
909
910
910
constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
911
911
912
- // Check against previous transactions
912
+ // Check input scripts and signatures.
913
913
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
914
914
if (!CheckInputScripts (tx, state, m_view, scriptVerifyFlags, true , false , txdata)) {
915
915
// SCRIPT_VERIFY_CLEANSTACK requires SCRIPT_VERIFY_WITNESS, so we
@@ -1469,8 +1469,10 @@ void InitScriptExecutionCache() {
1469
1469
}
1470
1470
1471
1471
/* *
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.
1474
1476
*
1475
1477
* If pvChecks is not nullptr, script checks are pushed onto it instead of being performed inline. Any
1476
1478
* script checks which are not necessary (eg due to script execution cache hits) are, obviously,
0 commit comments