From fa81568fb6036fbdf51d22e549200b633d4f50bd Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sun, 11 Dec 2022 18:59:24 +0000 Subject: [PATCH] locktime: add `FromHexStr` impl for `LockTime` This will be tested in a later commit, when `PackedLockTime` is folded into this type so all its tests apply to `LockTime`. --- bitcoin/src/blockdata/locktime/absolute.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bitcoin/src/blockdata/locktime/absolute.rs b/bitcoin/src/blockdata/locktime/absolute.rs index 212c3863..19e67b07 100644 --- a/bitcoin/src/blockdata/locktime/absolute.rs +++ b/bitcoin/src/blockdata/locktime/absolute.rs @@ -423,6 +423,15 @@ impl fmt::Display for LockTime { } } +impl FromHexStr for LockTime { + type Error = Error; + + fn from_hex_str_no_prefix + Into>(s: S) -> Result { + let packed_lock_time = crate::parse::hex_u32(s)?; + Ok(Self::from_consensus(packed_lock_time)) + } +} + impl Encodable for LockTime { #[inline] fn consensus_encode(&self, w: &mut W) -> Result {