Skip to content

Commit

Permalink
consensus: add TimeLockInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 8, 2023
1 parent 5cff076 commit 1963ee9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions consensus/src/timelocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,27 @@ impl FromStr for LockHeight {
}
}
}

/// Time lock interval describing both relative (OP_CHECKSEQUENCEVERIFY) and
/// absolute (OP_CHECKTIMELOCKVERIFY) timelocks.
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, From)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_BITCOIN, tags = order)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
pub enum TimeLockInterval {
/// Describes number of blocks for the timelock
#[from]
Height(LockHeight),

/// Describes number of 512-second intervals for the timelock
#[from]
Time(LockTimestamp),
}

impl Default for TimeLockInterval {
fn default() -> Self { TimeLockInterval::Height(default!()) }
}

0 comments on commit 1963ee9

Please sign in to comment.