@@ -178,20 +178,12 @@ 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 CheckFinalTxAtTip (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-
194- // CheckFinalTx() uses active_chain_tip.Height()+1 to evaluate
186+ // CheckFinalTxAtTip() uses active_chain_tip.Height()+1 to evaluate
195187 // nLockTime because when IsFinalTx() is called within
196188 // AcceptBlock(), the height of the block *being*
197189 // evaluated is what is used. Thus if we want to know if a
@@ -203,26 +195,23 @@ 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
214- bool CheckSequenceLocks (CBlockIndex* tip,
204+ bool CheckSequenceLocksAtTip (CBlockIndex* tip,
215205 const CCoinsView& coins_view,
216206 const CTransaction& tx,
217- int flags,
218207 LockPoints* lp,
219208 bool useExistingLockPoints)
220209{
221210 assert (tip != nullptr );
222211
223212 CBlockIndex index;
224213 index.pprev = tip;
225- // CheckSequenceLocks () uses active_chainstate.m_chain.Height()+1 to evaluate
214+ // CheckSequenceLocksAtTip () uses active_chainstate.m_chain.Height()+1 to evaluate
226215 // height based locks because when SequenceLocks() is called within
227216 // ConnectBlock(), the height of the block *being*
228217 // evaluated is what is used.
@@ -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 ;
@@ -268,7 +257,7 @@ bool CheckSequenceLocks(CBlockIndex* tip,
268257 // lockPair from CalculateSequenceLocks against tip+1. We know
269258 // EvaluateSequenceLocks will fail if there was a non-zero sequence
270259 // lock on a mempool input, so we can use the return value of
271- // CheckSequenceLocks to indicate the LockPoints validity
260+ // CheckSequenceLocksAtTip to indicate the LockPoints validity
272261 int maxInputHeight = 0 ;
273262 for (const int height : prevheights) {
274263 // Can ignore mempool inputs since we'll fail if they had non-zero locks
@@ -358,26 +347,26 @@ void CChainState::MaybeUpdateMempoolForReorg(
358347 // Also updates valid entries' cached LockPoints if needed.
359348 // If false, the tx is still valid and its lockpoints are updated.
360349 // If true, the tx would be invalid in the next block; remove this entry and all of its descendants.
361- const auto filter_final_and_mature = [this , flags=STANDARD_LOCKTIME_VERIFY_FLAGS ](CTxMemPool::txiter it)
350+ const auto filter_final_and_mature = [this ](CTxMemPool::txiter it)
362351 EXCLUSIVE_LOCKS_REQUIRED (m_mempool->cs , ::cs_main) {
363352 AssertLockHeld (m_mempool->cs );
364353 AssertLockHeld (::cs_main);
365354 const CTransaction& tx = it->GetTx ();
366355
367356 // The transaction must be final.
368- if (!CheckFinalTx (m_chain.Tip (), tx, flags )) return true ;
357+ if (!CheckFinalTxAtTip (m_chain.Tip (), tx)) return true ;
369358 LockPoints lp = it->GetLockPoints ();
370359 const bool validLP{TestLockPointValidity (m_chain, lp)};
371360 CCoinsViewMemPool view_mempool (&CoinsTip (), *m_mempool);
372- // CheckSequenceLocks checks if the transaction will be final in the next block to be
361+ // CheckSequenceLocksAtTip checks if the transaction will be final in the next block to be
373362 // created on top of the new chain. We use useExistingLockPoints=false so that, instead of
374363 // using the information in lp (which might now refer to a block that no longer exists in
375364 // the chain), it will update lp to contain LockPoints relevant to the new chain.
376- if (!CheckSequenceLocks (m_chain.Tip (), view_mempool, tx, flags , &lp, validLP)) {
377- // If CheckSequenceLocks fails, remove the tx and don't depend on the LockPoints.
365+ if (!CheckSequenceLocksAtTip (m_chain.Tip (), view_mempool, tx, &lp, validLP)) {
366+ // If CheckSequenceLocksAtTip fails, remove the tx and don't depend on the LockPoints.
378367 return true ;
379368 } else if (!validLP) {
380- // If CheckSequenceLocks succeeded, it also updated the LockPoints.
369+ // If CheckSequenceLocksAtTip succeeded, it also updated the LockPoints.
381370 // Now update the mempool entry lockpoints as well.
382371 m_mempool->mapTx .modify (it, [&lp](CTxMemPoolEntry& e) { e.UpdateLockPoints (lp); });
383372 }
@@ -722,8 +711,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
722711 // Only accept nLockTime-using transactions that can be mined in the next
723712 // block; we don't want our mempool filled up with transactions that can't
724713 // be mined yet.
725- if (!CheckFinalTx (m_active_chainstate.m_chain .Tip (), tx, STANDARD_LOCKTIME_VERIFY_FLAGS))
714+ if (!CheckFinalTxAtTip (m_active_chainstate.m_chain .Tip (), tx)) {
726715 return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-final" );
716+ }
727717
728718 if (m_pool.exists (GenTxid::Wtxid (tx.GetWitnessHash ()))) {
729719 // Exact transaction already exists in the mempool.
@@ -803,8 +793,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
803793 // be mined yet.
804794 // Pass in m_view which has all of the relevant inputs cached. Note that, since m_view's
805795 // backend was removed, it no longer pulls coins from the mempool.
806- if (!CheckSequenceLocks (m_active_chainstate.m_chain .Tip (), m_view, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
796+ if (!CheckSequenceLocksAtTip (m_active_chainstate.m_chain .Tip (), m_view, tx, &lp)) {
807797 return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-BIP68-final" );
798+ }
808799
809800 // The mempool holds txs for the next block, so pass height+1 to CheckTxInputs
810801 if (!Consensus::CheckTxInputs (tx, state, m_view, m_active_chainstate.m_chain .Height () + 1 , ws.m_base_fees )) {
0 commit comments