feat(txbuilder): compute ScriptDataHash including edge cases (#525)

Co-authored-by: kalomaaan <kalomaaan@gmail.com>
This commit is contained in:
Santiago Carmuega 2024-10-22 22:20:58 -03:00 committed by GitHub
parent 061a7796d6
commit 698d7a4933
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 282 additions and 94 deletions

View file

@ -232,6 +232,14 @@ where
pub fn to_vec(self) -> Vec<(K, V)> {
self.into()
}
pub fn from_vec(x: Vec<(K, V)>) -> Option<Self> {
if x.is_empty() {
None
} else {
Some(NonEmptyKeyValuePairs::Def(x))
}
}
}
impl<K, V> From<NonEmptyKeyValuePairs<K, V>> for Vec<(K, V)>
@ -777,6 +785,14 @@ impl<T> NonEmptySet<T> {
pub fn to_vec(self) -> Vec<T> {
self.0
}
pub fn from_vec(x: Vec<T>) -> Option<Self> {
if x.is_empty() {
None
} else {
Some(Self(x))
}
}
}
impl<T> Deref for NonEmptySet<T> {