| 153 | EXCLUSIVE_LOCKS_REQUIRED(cs_main); |
| 154 | |
| 155 | bool CheckFinalTxAtTip(const CBlockIndex& active_chain_tip, const CTransaction& tx) |
| 156 | { |
| 157 | AssertLockHeld(cs_main); |
| 158 | |
| 159 | // CheckFinalTxAtTip() uses active_chain_tip.Height()+1 to evaluate |
| 160 | // nLockTime because when IsFinalTx() is called within |
| 161 | // AcceptBlock(), the height of the block *being* |
| 162 | // evaluated is what is used. Thus if we want to know if a |
| 163 | // transaction can be part of the *next* block, we need to call |
| 164 | // IsFinalTx() with one more than active_chain_tip.Height(). |
| 165 | const int nBlockHeight = active_chain_tip.nHeight + 1; |
| 166 | |
| 167 | // BIP113 requires that time-locked transactions have nLockTime set to |
| 168 | // less than the median time of the previous block they're contained in. |
| 169 | // When the next block is created its previous block will be the current |
| 170 | // chain tip, so we use that to calculate the median time passed to |
| 171 | // IsFinalTx(). |
| 172 | const int64_t nBlockTime{active_chain_tip.GetMedianTimePast()}; |
| 173 | |
| 174 | return IsFinalTx(tx, nBlockHeight, nBlockTime); |
| 175 | } |
| 176 | |
| 177 | namespace { |
| 178 | /** |