Skip to content

Commit 9766e30

Browse files
committed
Fix bug in exec stack elements calculation
1 parent db97c39 commit 9766e30

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/miniscript/types/extra_props.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ impl Property for ExtData {
678678
}
679679

680680
fn or_d(l: Self, r: Self) -> Result<Self, ErrorKind> {
681-
Ok(ExtData {
681+
let res = ExtData {
682682
pk_cost: l.pk_cost + r.pk_cost + 3,
683683
has_free_verify: false,
684684
ops_count_static: l.ops_count_static + r.ops_count_static + 1,
@@ -708,14 +708,15 @@ impl Property for ExtData {
708708
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
709709
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
710710
exec_stack_elem_count_sat: cmp::max(
711-
opt_max(l.exec_stack_elem_count_sat, r.exec_stack_elem_count_dissat),
712-
r.exec_stack_elem_count_sat,
711+
l.exec_stack_elem_count_sat,
712+
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
713713
),
714714
exec_stack_elem_count_dissat: opt_max(
715715
l.exec_stack_elem_count_dissat,
716716
r.exec_stack_elem_count_dissat.map(|x| x + 1),
717717
),
718-
})
718+
};
719+
Ok(res)
719720
}
720721

721722
fn or_c(l: Self, r: Self) -> Result<Self, ErrorKind> {
@@ -743,8 +744,8 @@ impl Property for ExtData {
743744
max_dissat_size: None,
744745
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
745746
exec_stack_elem_count_sat: cmp::max(
746-
opt_max(l.exec_stack_elem_count_sat, r.exec_stack_elem_count_dissat),
747-
r.exec_stack_elem_count_sat,
747+
l.exec_stack_elem_count_sat,
748+
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
748749
),
749750
exec_stack_elem_count_dissat: None,
750751
})

0 commit comments

Comments
 (0)