LearnBitcoin

Glossary

BIP 113

Specified using Median Time Past instead of block header timestamps for locktime calculations, limiting miner timestamp manipulation.

BIP-113 changed the meaning of "current time" for Bitcoin Script locktime evaluation, from "the spending block's own timestamp" to "the median time of the previous 11 blocks" (MTP). Activated as a soft fork in July 2016 alongside BIP-68 and BIP-112 (CSV).

The problem it solved: miners have some discretion over block timestamps. The protocol allows a block's timestamp to be slightly off real time (loosely bounded by the previous block's MTP and a future-time limit). A miner could artificially advance the timestamp by up to ~2 hours and make time-locked transactions valid earlier than the user intended.

BIP-113's fix: use MTP - the median of the previous 11 blocks' timestamps - as the reference for time-based locktime evaluation. MTP is much more resistant to manipulation: a single miner can't move it, and even a colluding group of miners can only shift it by a bounded amount.

The result: time-based locktimes (set via nLockTime or CLTV) now behave predictably. A transaction specifying "valid after Jan 1 2027 00:00 UTC" won't be confirmed earlier just because one miner sets a clever timestamp.

BIP-113 is small, technical, and quietly important. Every time-based Lightning channel close, every HTLC timeout, every vault delay relies on MTP being a stable reference. Without BIP-113, all of those would be subject to miner timestamp shenanigans.

See Median Time Past for the underlying concept.

Key takeaways

  • Removes trust in miner timestamps for locktime
  • Uses median of recent blocks as a stable reference
  • Helps maintain consistent, tamper-resistant block timing

Related terms (9)