MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckFinalTxAtTip

Function CheckFinalTxAtTip

src/validation.cpp:155–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153 EXCLUSIVE_LOCKS_REQUIRED(cs_main);
154
155bool 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
177namespace {
178/**

Callers 3

PreChecksMethod · 0.85
TestBasicMiningMethod · 0.85

Calls 2

IsFinalTxFunction · 0.85
GetMedianTimePastMethod · 0.80

Tested by 1

TestBasicMiningMethod · 0.68