Source / pinned edition
Median time-past as endpoint for lock-time calculations
Source of package btc.consensus · BIP 113
- work
- urn:btc:clir:consensus#BIP113
- number
- BIP 113
- kind
- urn:btc:clir:consensus#other
BIP 113 raw MediaWiki at 7fe0b034ec967b52a5a28276419117326df93263
- edition
- urn:btc:clir:consensus#BIP113_RAW
- language
- en
- officiality
- official
- materialisation
- PINNED_OFFICIAL_BYTES
- life cycle
- —
Publications
| URI | Type | documentHash | Retrieved |
|---|---|---|---|
| https://raw.githubusercontent.com/bitcoin/bips/7fe0b034ec967b52a5a28276419117326df93263/bip-0113.mediawiki | text/plain; charset=utf-8 | sha256:f0643ba529837a673015a37287c21972bfa24cebfdc67e2844c6ad8d51d1ea69 | 2026-08-31T00:00:00Z |
Fragments — 1
Specification · section · referenced by: 4
en · official · sha256:d1ca9987b1c7d12b2e6778a8d1d424892071264daa441f715cd87c62bffc3fa3
The values for transaction locktime remain unchanged. The difference is only in
the calculation determining whether a transaction can be included. Instead of
an unreliable timestamp, the following function is used to determine the current
block time for the purpose of checking lock-time constraints:
enum { nMedianTimeSpan=11 };
int64_t GetMedianTimePast(const CBlockIndex* pindex)
{
int64_t pmedian[nMedianTimeSpan];
int64_t* pbegin = &pmedian[nMedianTimeSpan];
int64_t* pend = &pmedian[nMedianTimeSpan];
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
*(--pbegin) = pindex->GetBlockTime();
std::sort(pbegin, pend);
return pbegin[(pend - pbegin)/2];
}
Lock-time constraints are checked by the consensus method IsFinalTx().
This method takes the block time as one parameter. This BIP proposes
that after activation calls to IsFinalTx() within consensus code use
the return value of `GetMedianTimePast(pindexPrev)` instead.
The new rule applies to all transactions, including the coinbase transaction.Referencing norms: TimeLocktimeUsesPreviousMtp, nlocktime_median_time, previous_block_median_time_for_tx, timestamp_strictly_after_median_of_11_predecessors
The hash beside the text is the sha256 of its exact bytes. It is the check that the text shown matches the one pinned in the package: a divergence fails the oracle’s static analysis.