diff --git a/crates/bdk/src/descriptor/policy.rs b/crates/bdk/src/descriptor/policy.rs index 5de20ae7a..e29a2c230 100644 --- a/crates/bdk/src/descriptor/policy.rs +++ b/crates/bdk/src/descriptor/policy.rs @@ -39,7 +39,7 @@ use crate::collections::{BTreeMap, HashSet, VecDeque}; use alloc::string::String; use alloc::vec::Vec; -use core::cmp::max; +use core::cmp::{max, Ordering}; use core::fmt; use serde::ser::SerializeMap; @@ -495,6 +495,16 @@ impl Condition { } } +impl Ord for Condition { + fn cmp(&self, other: &Self) -> Ordering { + self.csv.cmp(&other.csv).then_with(|| { + self.timelock + .map(|t| t.to_consensus_u32()) + .cmp(&other.timelock.map(|t| t.to_consensus_u32())) + }) + } +} + /// Errors that can happen while extracting and manipulating policies #[derive(Debug, PartialEq, Eq)] pub enum PolicyError {