@@ -671,14 +671,8 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
671671
672672bool IsFinalTx (const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
673673{
674- AssertLockHeld (cs_main);
675- // Time based nLockTime implemented in 0.1.6
676674 if (tx.nLockTime == 0 )
677675 return true ;
678- if (nBlockHeight == 0 )
679- nBlockHeight = chainActive.Height ();
680- if (nBlockTime == 0 )
681- nBlockTime = GetAdjustedTime ();
682676 if ((int64_t )tx.nLockTime < ((int64_t )tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t )nBlockHeight : nBlockTime))
683677 return true ;
684678 BOOST_FOREACH (const CTxIn& txin, tx.vin )
@@ -687,6 +681,12 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
687681 return true ;
688682}
689683
684+ bool CheckFinalTx (const CTransaction &tx)
685+ {
686+ AssertLockHeld (cs_main);
687+ return IsFinalTx (tx, chainActive.Height () + 1 , GetAdjustedTime ());
688+ }
689+
690690/* *
691691 * Check transaction inputs to mitigate two
692692 * potential denial-of-service attacks:
@@ -903,21 +903,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
903903 // Only accept nLockTime-using transactions that can be mined in the next
904904 // block; we don't want our mempool filled up with transactions that can't
905905 // be mined yet.
906- //
907- // However, IsFinalTx() is confusing... Without arguments, it uses
908- // chainActive.Height() to evaluate nLockTime; when a block is accepted,
909- // chainActive.Height() is set to the value of nHeight in the block.
910- // However, when IsFinalTx() is called within CBlock::AcceptBlock(), the
911- // height of the block *being* evaluated is what is used. Thus if we want
912- // to know if a transaction can be part of the *next* block, we need to
913- // call IsFinalTx() with one more than chainActive.Height().
914- //
915- // Timestamps on the other hand don't get any special treatment, because we
916- // can't know what timestamp the next block will have, and there aren't
917- // timestamp applications where it matters.
918- if (!IsFinalTx (tx, chainActive.Height () + 1 ))
919- return state.DoS (0 ,
920- error (" AcceptToMemoryPool: non-final" ),
906+ if (!CheckFinalTx (tx))
907+ return state.DoS (0 , error (" AcceptToMemoryPool: non-final" ),
921908 REJECT_NONSTANDARD, " non-final" );
922909
923910 // is it already in the memory pool?
0 commit comments