Skip to content

Commit 4114967

Browse files
committed
Merge #772: feat: check policy validity to prevent duplicate check
757daee feat: check policy validity in from_ast to prevent duplicate check (ChrisCho-H) Pull request description: - `Miniscript::from_ast()` only executes `check_global_consensus_validity()` which does not include `check_global_policy_validity()`. Change to use `check_global_validity()` to check both consensus and policy validness. - `wrap_into_miniscript()` executes `check_global_validity()` internally after `Miniscript::from_ast()`. As `Miniscript::from_ast()` now executes `check_global_validity()`, it doesn't have to check duplicately. I was originally thinking to change `check_global_validity()` inside `wrap_into_miniscript()` to `check_global_policy_validity()`(as consensus check is done by `from_ast()`). I think it's better to strengthen the validness check in `from_ast()`, and do nothing in `wrap_into_miniscript()`. ACKs for top commit: apoelstra: ACK 757daee; successfully ran local tests Tree-SHA512: e6afc44b8e5fa9310d6656f1d624f8f3b25c893c02e6e2936e924e5e78f0d4beba53c5114c49348a572d1ea5a2b3af4739bc6bcd8ea22c968b3cc47c6f521bd3
2 parents e35eb70 + 757daee commit 4114967

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/miniscript/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ mod private {
174174
if (res.ext.tree_height as u32) > MAX_RECURSION_DEPTH {
175175
return Err(Error::MaxRecursiveDepthExceeded);
176176
}
177-
Ctx::check_global_consensus_validity(&res)?;
177+
Ctx::check_global_validity(&res)?;
178178
Ok(res)
179179
}
180180

@@ -742,7 +742,6 @@ where
742742
for ch in frag_wrap.chars().rev() {
743743
// Check whether the wrapper is valid under the current context
744744
let ms = Miniscript::from_ast(unwrapped)?;
745-
Ctx::check_global_validity(&ms)?;
746745
match ch {
747746
'a' => unwrapped = Terminal::Alt(Arc::new(ms)),
748747
's' => unwrapped = Terminal::Swap(Arc::new(ms)),
@@ -759,7 +758,6 @@ where
759758
}
760759
// Check whether the unwrapped miniscript is valid under the current context
761760
let ms = Miniscript::from_ast(unwrapped)?;
762-
Ctx::check_global_validity(&ms)?;
763761
Ok(ms)
764762
}
765763

0 commit comments

Comments
 (0)