@@ -178,19 +178,11 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
178178 std::vector<CScriptCheck>* pvChecks = nullptr )
179179 EXCLUSIVE_LOCKS_REQUIRED(cs_main);
180180
181- bool CheckFinalTx (const CBlockIndex* active_chain_tip, const CTransaction &tx, int flags )
181+ bool CheckFinalTx (const CBlockIndex* active_chain_tip, const CTransaction& tx )
182182{
183183 AssertLockHeld (cs_main);
184184 assert (active_chain_tip); // TODO: Make active_chain_tip a reference
185185
186- // By convention a negative value for flags indicates that the
187- // current network-enforced consensus rules should be used. In
188- // a future soft-fork scenario that would mean checking which
189- // rules would be enforced for the next block and setting the
190- // appropriate flags. At the present time no soft-forks are
191- // scheduled, so no flags are set.
192- flags = std::max (flags, 0 );
193-
194186 // CheckFinalTx() uses active_chain_tip.Height()+1 to evaluate
195187 // nLockTime because when IsFinalTx() is called within
196188 // AcceptBlock(), the height of the block *being*
@@ -203,18 +195,15 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
203195 // less than the median time of the previous block they're contained in.
204196 // When the next block is created its previous block will be the current
205197 // chain tip, so we use that to calculate the median time passed to
206- // IsFinalTx() if LOCKTIME_MEDIAN_TIME_PAST is set.
207- const int64_t nBlockTime = (flags & LOCKTIME_MEDIAN_TIME_PAST)
208- ? active_chain_tip->GetMedianTimePast ()
209- : GetAdjustedTime ();
198+ // IsFinalTx().
199+ const int64_t nBlockTime{active_chain_tip->GetMedianTimePast ()};
210200
211201 return IsFinalTx (tx, nBlockHeight, nBlockTime);
212202}
213203
214204bool CheckSequenceLocks (CBlockIndex* tip,
215205 const CCoinsView& coins_view,
216206 const CTransaction& tx,
217- int flags,
218207 LockPoints* lp,
219208 bool useExistingLockPoints)
220209{
@@ -252,7 +241,7 @@ bool CheckSequenceLocks(CBlockIndex* tip,
252241 prevheights[txinIndex] = coin.nHeight ;
253242 }
254243 }
255- lockPair = CalculateSequenceLocks (tx, flags , prevheights, index);
244+ lockPair = CalculateSequenceLocks (tx, STANDARD_LOCKTIME_VERIFY_FLAGS , prevheights, index);
256245 if (lp) {
257246 lp->height = lockPair.first ;
258247 lp->time = lockPair.second ;
@@ -356,22 +345,22 @@ void CChainState::MaybeUpdateMempoolForReorg(
356345 // Also updates valid entries' cached LockPoints if needed.
357346 // If false, the tx is still valid and its lockpoints are updated.
358347 // If true, the tx would be invalid in the next block; remove this entry and all of its descendants.
359- const auto filter_final_and_mature = [this , flags=STANDARD_LOCKTIME_VERIFY_FLAGS ](CTxMemPool::txiter it)
348+ const auto filter_final_and_mature = [this ](CTxMemPool::txiter it)
360349 EXCLUSIVE_LOCKS_REQUIRED (m_mempool->cs , ::cs_main) {
361350 AssertLockHeld (m_mempool->cs );
362351 AssertLockHeld (::cs_main);
363352 const CTransaction& tx = it->GetTx ();
364353
365354 // The transaction must be final.
366- if (!CheckFinalTx (m_chain.Tip (), tx, flags )) return true ;
355+ if (!CheckFinalTx (m_chain.Tip (), tx)) return true ;
367356 LockPoints lp = it->GetLockPoints ();
368357 const bool validLP{TestLockPointValidity (m_chain, lp)};
369358 CCoinsViewMemPool view_mempool (&CoinsTip (), *m_mempool);
370359 // CheckSequenceLocks checks if the transaction will be final in the next block to be
371360 // created on top of the new chain. We use useExistingLockPoints=false so that, instead of
372361 // using the information in lp (which might now refer to a block that no longer exists in
373362 // the chain), it will update lp to contain LockPoints relevant to the new chain.
374- if (!CheckSequenceLocks (m_chain.Tip (), view_mempool, tx, flags, &lp, validLP)) {
363+ if (!CheckSequenceLocks (m_chain.Tip (), view_mempool, tx, &lp, validLP)) {
375364 // If CheckSequenceLocks fails, remove the tx and don't depend on the LockPoints.
376365 return true ;
377366 } else if (!validLP) {
@@ -699,8 +688,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
699688 // Only accept nLockTime-using transactions that can be mined in the next
700689 // block; we don't want our mempool filled up with transactions that can't
701690 // be mined yet.
702- if (!CheckFinalTx (m_active_chainstate.m_chain .Tip (), tx, STANDARD_LOCKTIME_VERIFY_FLAGS))
691+ if (!CheckFinalTx (m_active_chainstate.m_chain .Tip (), tx)) {
703692 return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-final" );
693+ }
704694
705695 if (m_pool.exists (GenTxid::Wtxid (tx.GetWitnessHash ()))) {
706696 // Exact transaction already exists in the mempool.
@@ -780,8 +770,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
780770 // be mined yet.
781771 // Pass in m_view which has all of the relevant inputs cached. Note that, since m_view's
782772 // backend was removed, it no longer pulls coins from the mempool.
783- if (!CheckSequenceLocks (m_active_chainstate.m_chain .Tip (), m_view, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
773+ if (!CheckSequenceLocks (m_active_chainstate.m_chain .Tip (), m_view, tx, &lp)) {
784774 return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-BIP68-final" );
775+ }
785776
786777 // The mempool holds txs for the next block, so pass height+1 to CheckTxInputs
787778 if (!Consensus::CheckTxInputs (tx, state, m_view, m_active_chainstate.m_chain .Height () + 1 , ws.m_base_fees )) {
0 commit comments