keep-starknet-strange / raito

Bitcoin ZK client written in Cairo.
https://raito.wtf
MIT License
40 stars 34 forks source link

[bug] Use median-time-past for input sequence checks rather than block time #231

Closed m-kus closed 3 weeks ago

m-kus commented 1 month ago

Problem

Currently OutPoint contains block_time field which is used to validate relative locktime — when the TXO can be spent only if enough time have past since the block containing that TXO.

However in Bitcoin core they use MTP (median time past) for that purpose: https://github.com/bitcoin/bitcoin/blob/712a2b5453cdf2568fece94b969d6e0923b6ba16/src/consensus/tx_verify.cpp#L74

MTP is the median of previous timestamps for the chain state preceding the target block.
We have this data, we just need to propagate it down to the place where it's needed.

Fix

fishonamos commented 1 month ago

Kindly assign @m-kus