@@ -415,7 +415,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
415
415
* */
416
416
static bool CheckInputsFromMempoolAndCache (const CTransaction& tx, TxValidationState& state,
417
417
const CCoinsViewCache& view, const CTxMemPool& pool,
418
- unsigned int flags, PrecomputedTransactionData& txdata)
418
+ unsigned int flags, PrecomputedTransactionData& txdata, CCoinsViewCache& coins_tip )
419
419
EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
420
420
{
421
421
AssertLockHeld (cs_main);
@@ -440,7 +440,8 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
440
440
assert (txFrom->vout .size () > txin.prevout .n );
441
441
assert (txFrom->vout [txin.prevout .n ] == coin.out );
442
442
} else {
443
- const Coin& coinFromUTXOSet = ::ChainstateActive ().CoinsTip ().AccessCoin (txin.prevout );
443
+ assert (std::addressof (::ChainstateActive ().CoinsTip ()) == std::addressof (coins_tip));
444
+ const Coin& coinFromUTXOSet = coins_tip.AccessCoin (txin.prevout );
444
445
assert (!coinFromUTXOSet.IsSpent ());
445
446
assert (coinFromUTXOSet.out == coin.out );
446
447
}
@@ -970,7 +971,7 @@ bool MemPoolAccept::ConsensusScriptChecks(const ATMPArgs& args, Workspace& ws, P
970
971
// invalid blocks (using TestBlockValidity), however allowing such
971
972
// transactions into the mempool can be exploited as a DoS attack.
972
973
unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags (::ChainActive ().Tip (), chainparams.GetConsensus ());
973
- if (!CheckInputsFromMempoolAndCache (tx, state, m_view, m_pool, currentBlockScriptVerifyFlags, txdata)) {
974
+ if (!CheckInputsFromMempoolAndCache (tx, state, m_view, m_pool, currentBlockScriptVerifyFlags, txdata, :: ChainstateActive (). CoinsTip () )) {
974
975
return error (" %s: BUG! PLEASE REPORT THIS! CheckInputScripts failed against latest-block but not STANDARD flags %s, %s" ,
975
976
__func__, hash.ToString (), state.ToString ());
976
977
}
0 commit comments