@@ -178,19 +178,11 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
178
178
std::vector<CScriptCheck>* pvChecks = nullptr )
179
179
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
180
180
181
- bool CheckFinalTx (const CBlockIndex* active_chain_tip, const CTransaction &tx, int flags )
181
+ bool CheckFinalTx (const CBlockIndex* active_chain_tip, const CTransaction& tx )
182
182
{
183
183
AssertLockHeld (cs_main);
184
184
assert (active_chain_tip); // TODO: Make active_chain_tip a reference
185
185
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
186
// CheckFinalTx() uses active_chain_tip.Height()+1 to evaluate
195
187
// nLockTime because when IsFinalTx() is called within
196
188
// AcceptBlock(), the height of the block *being*
@@ -203,18 +195,15 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
203
195
// less than the median time of the previous block they're contained in.
204
196
// When the next block is created its previous block will be the current
205
197
// 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 ()};
210
200
211
201
return IsFinalTx (tx, nBlockHeight, nBlockTime);
212
202
}
213
203
214
204
bool CheckSequenceLocks (CBlockIndex* tip,
215
205
const CCoinsView& coins_view,
216
206
const CTransaction& tx,
217
- int flags,
218
207
LockPoints* lp,
219
208
bool useExistingLockPoints)
220
209
{
@@ -252,7 +241,7 @@ bool CheckSequenceLocks(CBlockIndex* tip,
252
241
prevheights[txinIndex] = coin.nHeight ;
253
242
}
254
243
}
255
- lockPair = CalculateSequenceLocks (tx, flags , prevheights, index);
244
+ lockPair = CalculateSequenceLocks (tx, STANDARD_LOCKTIME_VERIFY_FLAGS , prevheights, index);
256
245
if (lp) {
257
246
lp->height = lockPair.first ;
258
247
lp->time = lockPair.second ;
@@ -356,22 +345,22 @@ void CChainState::MaybeUpdateMempoolForReorg(
356
345
// Also updates valid entries' cached LockPoints if needed.
357
346
// If false, the tx is still valid and its lockpoints are updated.
358
347
// 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)
360
349
EXCLUSIVE_LOCKS_REQUIRED (m_mempool->cs , ::cs_main) {
361
350
AssertLockHeld (m_mempool->cs );
362
351
AssertLockHeld (::cs_main);
363
352
const CTransaction& tx = it->GetTx ();
364
353
365
354
// The transaction must be final.
366
- if (!CheckFinalTx (m_chain.Tip (), tx, flags )) return true ;
355
+ if (!CheckFinalTx (m_chain.Tip (), tx)) return true ;
367
356
LockPoints lp = it->GetLockPoints ();
368
357
const bool validLP{TestLockPointValidity (m_chain, lp)};
369
358
CCoinsViewMemPool view_mempool (&CoinsTip (), *m_mempool);
370
359
// CheckSequenceLocks checks if the transaction will be final in the next block to be
371
360
// created on top of the new chain. We use useExistingLockPoints=false so that, instead of
372
361
// using the information in lp (which might now refer to a block that no longer exists in
373
362
// 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)) {
375
364
// If CheckSequenceLocks fails, remove the tx and don't depend on the LockPoints.
376
365
return true ;
377
366
} else if (!validLP) {
@@ -699,8 +688,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
699
688
// Only accept nLockTime-using transactions that can be mined in the next
700
689
// block; we don't want our mempool filled up with transactions that can't
701
690
// 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)) {
703
692
return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-final" );
693
+ }
704
694
705
695
if (m_pool.exists (GenTxid::Wtxid (tx.GetWitnessHash ()))) {
706
696
// Exact transaction already exists in the mempool.
@@ -780,8 +770,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
780
770
// be mined yet.
781
771
// Pass in m_view which has all of the relevant inputs cached. Note that, since m_view's
782
772
// 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)) {
784
774
return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-BIP68-final" );
775
+ }
785
776
786
777
// The mempool holds txs for the next block, so pass height+1 to CheckTxInputs
787
778
if (!Consensus::CheckTxInputs (tx, state, m_view, m_active_chainstate.m_chain .Height () + 1 , ws.m_base_fees )) {
0 commit comments