relative locktime: use From/TryFrom to convert between relative locktimes and Sequence
This commit is contained in:
parent
0ed26915f6
commit
319e102fed
|
@ -6,7 +6,7 @@
|
||||||
//! whether bit 22 of the `u32` consensus value is set.
|
//! whether bit 22 of the `u32` consensus value is set.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use core::{cmp, fmt};
|
use core::{cmp, convert, fmt};
|
||||||
|
|
||||||
#[cfg(all(test, mutate))]
|
#[cfg(all(test, mutate))]
|
||||||
use mutagen::mutate;
|
use mutagen::mutate;
|
||||||
|
@ -307,6 +307,17 @@ impl fmt::Display for LockTime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl convert::TryFrom<Sequence> for LockTime {
|
||||||
|
type Error = DisabledLockTimeError;
|
||||||
|
fn try_from(seq: Sequence) -> Result<LockTime, DisabledLockTimeError> {
|
||||||
|
LockTime::from_sequence(seq)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<LockTime> for Sequence {
|
||||||
|
fn from(lt: LockTime) -> Sequence { lt.to_sequence() }
|
||||||
|
}
|
||||||
|
|
||||||
/// Error returned when a sequence number is parsed as a lock time, but its
|
/// Error returned when a sequence number is parsed as a lock time, but its
|
||||||
/// "disable" flag is set.
|
/// "disable" flag is set.
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
|
|
Loading…
Reference in New Issue