Miniscript - Add Literal Boolean Operators #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In another finding from the Bitcoinfuzz project by @brunoerg, we learned that, unlike Core and Rust Miniscript, Embit won't parse booleans,
0and1, as arguments for logical operators likeand_v. Currently, a miniscript like"wsh(and_v(v:0,and_v(v:0,0)))"raises an error:Unknown operator '0,and_v'.This PR aims to enable Embit to properly load and compile boolean literals by implementing the
JustZeroandJustOneminiscript objects and refactoring the parsing algorithm.Although booleans have little or no use in practical miniscripts, being able to parse them is important for standardizing behavior across different miniscript implementations.
Kudos to @brunoerg and @erickcestari for pointing the issue.
Thanks @jdlcdl for the guidance through all the process, from understanding the issue, the code, and for the multiple reviews.
Note: A second issue involving the recursive depth limit in the Fuzz test case remains, even after resolving the boolean support, and will not be covered by this PR.