Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crates/bdk/src/descriptor/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down