Skip to content
Closed
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions src/miniscript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2216,4 +2216,32 @@ mod tests {
);
}
}
#[test]
fn thresh_expressive_bip379() {
// BIP379 computes the "e" property of a thresh as "all are s"; the "m"
// property is what additionally requires every child to be "e".
//
// or_i(pk(A),pk(B)) is a legal thresh child (Bdu) which is "s" but not
// "e", so a threshold over such children discriminates between the two
// rules. Such a threshold is malleable either way, which is why the
// distinction is not observable through is_non_malleable().
let child = Miniscript::<String, Segwitv0>::from_str_insane("or_i(pk(A),pk(B))").unwrap();
assert!(child.ty.mall.signed);
assert_eq!(child.ty.mall.dissat, types::Dissat::Unknown);

let ms = Miniscript::<String, Segwitv0>::from_str_insane(
"thresh(2,or_i(pk(A),pk(B)),a:or_i(pk(C),pk(D)))",
)
.unwrap();
assert_eq!(ms.ty.mall.dissat, types::Dissat::Unique);
assert!(!ms.ty.mall.non_malleable);

// A threshold with a non-signed child is not "e" under either rule.
let ms = Miniscript::<String, Segwitv0>::from_str_insane(&format!(
"thresh(2,or_i(pk(A),pk(B)),a:sha256({}))",
sha256::Hash::hash(&[])
))
.unwrap();
assert_eq!(ms.ty.mall.dissat, types::Dissat::Unknown);
}
}
Loading
Loading