Chain time (MTP)

Why every covenant decision uses median-time-past, and what that means for deadlines and Dutch decay.

Covenants can't read the wall clock. They can read tx.locktime (the transaction's nLocktime) and check it against the chain via tx.time requirements. The protocol uses median-time-past (MTP), the median timestamp of the last 11 block headers, as its only clock.

The rules

  1. A transaction is final only if nLocktime < MTP. nLocktime = MTP is rejected as bad-txns-nonfinal.
  2. The server's chainClock.finalLocktime() returns MTP − 1: the latest locktime that is final right now.
  3. Every fill uses that locktime, so the covenant's "now" is MTP − 1.
  4. Intent times (expiryTime, startTime) are anchored to the final locktime at creation.

Consequences

Note: > If you build fills yourself, never use Date.now() for nLocktime. Read the last 11 block headers from your Electrum server, take the median timestamp and subtract one.