diff --git a/bitcoin/src/blockdata/mod.rs b/bitcoin/src/blockdata/mod.rs index 36b4ce410..ee1c770f8 100644 --- a/bitcoin/src/blockdata/mod.rs +++ b/bitcoin/src/blockdata/mod.rs @@ -72,8 +72,12 @@ pub mod locktime { /// Re-export everything from the `primitives::locktime::relative` module. pub use primitives::locktime::relative::{ DisabledLockTimeError, Height, IncompatibleHeightError, IncompatibleTimeError, - LockTime, Time, TimeOverflowError, + LockTime, MtpInterval, TimeOverflowError, }; + + #[deprecated(since = "TBD", note = "use `Mtp` instead")] + #[doc(hidden)] + pub type Time = MtpInterval; } } diff --git a/primitives/src/locktime/relative.rs b/primitives/src/locktime/relative.rs index 3493e37ff..8b7278c60 100644 --- a/primitives/src/locktime/relative.rs +++ b/primitives/src/locktime/relative.rs @@ -13,9 +13,13 @@ use crate::{relative, TxIn}; #[rustfmt::skip] // Keep public re-exports separate. #[doc(inline)] -pub use units::locktime::relative::{Height, Time, TimeOverflowError}; +pub use units::locktime::relative::{Height, MtpInterval, TimeOverflowError}; use units::mtp_height::MtpAndHeight; +#[deprecated(since = "TBD", note = "use `Mtp` instead")] +#[doc(hidden)] +pub type Time = MtpInterval; + /// A relative lock time value, representing either a block height or time (512 second intervals). /// /// Used for sequence numbers (`nSequence` in Bitcoin Core and [`TxIn::sequence`] @@ -61,7 +65,7 @@ use units::mtp_height::MtpAndHeight; /// /// let chain_tip = MtpAndHeight::new(current_height, timestamps); /// let utxo_mined_at = MtpAndHeight::new(utxo_height, utxo_timestamps); -/// let locktime = relative::LockTime::Time(relative::Time::from_512_second_intervals(10)); +/// let locktime = relative::LockTime::Time(relative::MtpInterval::from_512_second_intervals(10)); /// /// // Check if locktime is satisfied /// assert!(locktime.is_satisfied_by(chain_tip, utxo_mined_at)); @@ -72,7 +76,7 @@ pub enum LockTime { /// A block height lock time value. Blocks(Height), /// A 512 second time interval value. - Time(Time), + Time(MtpInterval), } impl LockTime { @@ -164,7 +168,7 @@ impl LockTime { /// [`Self::from_seconds_floor`] or [`Self::from_seconds_ceil`]. #[inline] pub const fn from_512_second_intervals(intervals: u16) -> Self { - LockTime::Time(Time::from_512_second_intervals(intervals)) + LockTime::Time(MtpInterval::from_512_second_intervals(intervals)) } /// Construct a new [`LockTime`] from seconds, converting the seconds into 512 second interval @@ -175,7 +179,7 @@ impl LockTime { /// Will return an error if the input cannot be encoded in 16 bits. #[inline] pub const fn from_seconds_floor(seconds: u32) -> Result { - match Time::from_seconds_floor(seconds) { + match MtpInterval::from_seconds_floor(seconds) { Ok(time) => Ok(LockTime::Time(time)), Err(e) => Err(e), } @@ -189,7 +193,7 @@ impl LockTime { /// Will return an error if the input cannot be encoded in 16 bits. #[inline] pub const fn from_seconds_ceil(seconds: u32) -> Result { - match Time::from_seconds_ceil(seconds) { + match MtpInterval::from_seconds_ceil(seconds) { Ok(time) => Ok(LockTime::Time(time)), Err(e) => Err(e), } @@ -363,7 +367,7 @@ impl LockTime { /// assert!(lock.is_satisfied_by_time(relative::Time::from_512_second_intervals(intervals + 10)).expect("a time")); /// ``` #[inline] - pub fn is_satisfied_by_time(self, time: Time) -> Result { + pub fn is_satisfied_by_time(self, time: MtpInterval) -> Result { use LockTime as L; match self { @@ -378,9 +382,9 @@ impl From for LockTime { fn from(h: Height) -> Self { LockTime::Blocks(h) } } -impl From