Skip to content

Add median-time-past (MTP) calculation to CheckPoint #2036

@evanlinjin

Description

@evanlinjin

Summary

Add median-time-past (MTP) calculation capability to CheckPoint for time-based validation in Bitcoin consensus rules.

Proposed Changes

  1. Extend ToBlockHash trait with optional block time:
fn block_time(&self) -> Option<u32> { None }
  1. Add median_time_past() method to CheckPoint:
    • Calculate median of up to 11 previous block timestamps
    • Return None if:
      • Data type doesn't support block times
      • Required blocks are missing (sparse chain)
      • Insufficient block history available

Use Cases

  • Transaction time-lock verification (nLockTime, OP_CHECKLOCKTIMEVERIFY)
  • BIP113 compliance

Notes

  • CheckPoint represents a sparse chain, so required blocks may not be available
  • MTP = median of current block + up to 10 predecessors (sorted timestamps)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions