@@ -693,6 +693,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
693693 // to coins_to_uncache)
694694 m_view.SetBackend (m_dummy);
695695
696+ assert (m_active_chainstate.m_blockman .LookupBlockIndex (m_view.GetBestBlock ()) == m_active_chainstate.m_chain .Tip ());
697+
696698 // Only accept BIP68 sequence locked transactions that can be mined in the next
697699 // block; we don't want our mempool filled up with transactions that can't
698700 // be mined yet.
@@ -701,7 +703,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
701703 if (!CheckSequenceLocks (m_active_chainstate.m_chain .Tip (), m_view, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
702704 return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-BIP68-final" );
703705
704- if (!Consensus::CheckTxInputs (tx, state, m_view, m_active_chainstate.m_blockman .GetSpendHeight (m_view), ws.m_base_fees )) {
706+ // The mempool holds txs for the next block, so pass height+1 to CheckTxInputs
707+ if (!Consensus::CheckTxInputs (tx, state, m_view, m_active_chainstate.m_chain .Height () + 1 , ws.m_base_fees )) {
705708 return false ; // state filled in by CheckTxInputs
706709 }
707710
@@ -1401,14 +1404,6 @@ bool CScriptCheck::operator()() {
14011404 return VerifyScript (scriptSig, m_tx_out.scriptPubKey , nFlags, CachingTransactionSignatureChecker (ptxTo, nIn, m_tx_out.nValue , txdata, cacheStore), &error);
14021405}
14031406
1404- int BlockManager::GetSpendHeight (const CCoinsViewCache& inputs)
1405- {
1406- AssertLockHeld (cs_main);
1407- CBlockIndex* pindexPrev = LookupBlockIndex (inputs.GetBestBlock ());
1408- return pindexPrev->nHeight + 1 ;
1409- }
1410-
1411-
14121407static CuckooCache::cache<uint256, SignatureCacheHasher> g_scriptExecutionCache;
14131408static CSHA256 g_scriptExecutionCacheHasher;
14141409
0 commit comments