Summary
Add median-time-past (MTP) calculation capability to CheckPoint for time-based validation in Bitcoin consensus rules.
Proposed Changes
- Extend
ToBlockHash trait with optional block time:
fn block_time(&self) -> Option<u32> { None }
- 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)
Summary
Add median-time-past (MTP) calculation capability to
CheckPointfor time-based validation in Bitcoin consensus rules.Proposed Changes
ToBlockHashtrait with optional block time:median_time_past()method toCheckPoint:Noneif:Use Cases
Notes
CheckPointrepresents a sparse chain, so required blocks may not be available