Bitcoin Median Time Past: Which of 11 Block Times Unlocks a Transaction?

A wallet clock reads 13:55 UTC. A transaction has an active time lock set to 12:50 UTC on the same date. Can the next Bitcoin block include it? The wallet clock alone cannot tell you. Bitcoin median time past uses timestamps from the preceding 11 blocks. For this locktime check, the median must be later than the time written into the transaction. An exact tie still leaves the transaction waiting.

Purple illustration of a webpage with the words “New Blog Post”.
Default illustration for Fradiqueland Blog.

Calculate Bitcoin median time past by hand

Take a hypothetical chain with eleven preceding block timestamps on the same date. In block-height order, their times are 12:02, 12:11, 12:09, 12:22, 12:37, 12:50, 12:58, 13:03, 13:15, 13:23 and 13:35 UTC. The third block carries an earlier timestamp than the second. Keep both entries. The calculation takes its sample by position in the chain and orders the times only after selecting the blocks.

Sorted from earliest to latest, the first five are 12:02, 12:09, 12:11, 12:22 and 12:37. The sixth is 12:50. Five later entries remain, so 12:50 is the median. There is no addition or division to do. A single very late value at the end of the list would leave the sixth value in the same place.

Read the three boundary cases

Suppose each of three otherwise identical transactions actually enforces its absolute time lock. Each uses a timestamp on our example date. Compare each threshold with the same 12:50 median computed from the parent block and its predecessors.

Time-lock results for a candidate block with a previous median of 12:50 UTC
Transaction locktimeHas the median passed it?
12:49Yes. This time condition passes.
12:50No. Equality still fails the condition.
12:51No. The threshold is still ahead.

Now add a block stamped 13:42 and calculate the median for its successor. The window drops the oldest block, stamped 12:02, and gains 13:42. The sixth sorted value becomes 12:58. All three sample thresholds are now earlier than the median. This second calculation uses a different set of eleven blocks. Changing a clock on the computer displaying the transaction would leave both calculations untouched.

What this calculation tells a reader

BIP 113, the deployed consensus specification, explains why the candidate block’s own timestamp was a poor clock for this decision. A miner choosing that timestamp had an incentive to advance it to include transactions and collect their fees. Looking back at the established chain changes which evidence determines eligibility. The eleven-block window is a count of blocks, so its span in minutes can vary.

A lock can also be expressed as a block height. The timestamp example above addresses a different question. Before applying it to a transaction you are reading, check the kind of threshold and whether the transaction enables it. Passing this single time condition establishes eligibility on that point alone. It promises neither inclusion in a particular block nor an exact confirmation time.

For a second example of two numbers that are easy to confuse when reading a transaction, see Fradiqueland’s guide to Bitcoin fee rate. There the denominator is virtual size. Here the comparison hinges on which block supplies the clock.

Check the window before drawing a conclusion

One easy mistake is to sort twelve timestamps and drop the smallest one. The window advances by block height. If the oldest block carried the third-smallest time, that is the entry that would leave. Write a height beside each timestamp, remove the oldest height, and only then sort the remaining eleven times. The two operations happen to give the same answer in our example because the earliest block also carried the earliest time.

Keep every timestamp in one time zone and retain the date. Minutes since noon are convenient here because the example falls on one afternoon. A real window can cross midnight. Sorting clock faces alone would then put a late-night block after a block from the following morning.

Leave a Comment

Scroll to Top