Skip to content

Commit cd9de92

Browse files
committed
Update multi_a to not include n wrapper
While we are at it, do not use the default impl. This makes these types of error easy to make. I think this could have easily been prevently if I was forced to explicitly write AnyNonZero in front of multi_a
1 parent a7bfff4 commit cd9de92

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/miniscript/types/correctness.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ impl Property for Correctness {
170170
}
171171
}
172172

173+
fn from_multi_a(_: usize, _: usize) -> Self {
174+
Correctness {
175+
base: Base::B,
176+
input: Input::Any,
177+
dissatisfiable: true,
178+
unit: true,
179+
}
180+
}
181+
173182
fn from_hash() -> Self {
174183
Correctness {
175184
base: Base::B,

src/miniscript/types/malleability.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ impl Property for Malleability {
119119
}
120120
}
121121

122+
fn from_multi_a(_: usize, _: usize) -> Self {
123+
Malleability {
124+
dissat: Dissat::Unique,
125+
safe: true,
126+
non_malleable: true,
127+
}
128+
}
129+
122130
fn from_hash() -> Self {
123131
Malleability {
124132
dissat: Dissat::Unknown,

src/miniscript/types/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ pub trait Property: Sized {
267267
fn from_multi(k: usize, n: usize) -> Self;
268268

269269
/// Type property of a `MultiA` fragment
270-
fn from_multi_a(k: usize, n: usize) -> Self {
271-
// default impl same as multi
272-
Self::from_multi(k, n)
273-
}
270+
fn from_multi_a(k: usize, n: usize) -> Self;
274271

275272
/// Type property of a hash fragment
276273
fn from_hash() -> Self;
@@ -583,6 +580,13 @@ impl Property for Type {
583580
}
584581
}
585582

583+
fn from_multi_a(k: usize, n: usize) -> Self {
584+
Type {
585+
corr: Property::from_multi_a(k, n),
586+
mall: Property::from_multi_a(k, n),
587+
}
588+
}
589+
586590
fn from_hash() -> Self {
587591
Type {
588592
corr: Property::from_hash(),

0 commit comments

Comments
 (0)