diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b958d62..b683d1cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Policy #### Changed - Removed unneeded `Result<(), PolicyError>` return type for `Satisfaction::finalize()` +- Removed the `TooManyItemsSelected` policy error (see commit message for more details) ## [v0.3.0] - [v0.2.0] diff --git a/src/descriptor/policy.rs b/src/descriptor/policy.rs index 54ba808b..40d8efb3 100644 --- a/src/descriptor/policy.rs +++ b/src/descriptor/policy.rs @@ -47,7 +47,7 @@ //! # Ok::<(), bdk::Error>(()) //! ``` -use std::cmp::{max, Ordering}; +use std::cmp::max; use std::collections::{BTreeMap, HashSet, VecDeque}; use std::fmt; @@ -510,8 +510,6 @@ impl Condition { pub enum PolicyError { /// Not enough items are selected to satisfy a [`SatisfiableItem::Thresh`] NotEnoughItemsSelected(String), - /// Too many items are selected to satisfy a [`SatisfiableItem::Thresh`] - TooManyItemsSelected(String), /// Index out of range for an item to satisfy a [`SatisfiableItem::Thresh`] IndexOutOfRange(usize), /// Can not add to an item that is [`Satisfaction::None`] or [`Satisfaction::Complete`] @@ -668,14 +666,8 @@ impl Policy { // if we have something, make sure we have enough items. note that the user can set // an empty value for this step in case of n-of-n, because `selected` is set to all // the elements above - match selected.len().cmp(threshold) { - Ordering::Less => { - return Err(PolicyError::NotEnoughItemsSelected(self.id.clone())) - } - Ordering::Greater => { - return Err(PolicyError::TooManyItemsSelected(self.id.clone())) - } - Ordering::Equal => (), + if selected.len() < *threshold { + return Err(PolicyError::NotEnoughItemsSelected(self.id.clone())); } // check the selected items, see if there are conflicting requirements