sipa / miniscript

Miniscript site and implementation
159 stars 47 forks source link

Unify the two satisfaction algorithms #102

Closed sipa closed 2 years ago

sipa commented 2 years ago

This changes the malleable satisfaction algorithm to produce the same result as the non-malleable one, in case a non-malleable satisfaction exists. Further, any non-malleable result gains the guarantee that it is valid assuming a new ValidSatisfaction(), which is weaker than IsSane(), and crucially, doesn't require IsNonMalleable().

Lots of code simplifications follow.

The downside is that this makes the malleable satisfaction algorithm less aggressively pursue minimal witness size (because it's internally using the same priorities as the non-malleable one). On the other hand, it simplifies the code, and makes it more testable (as demonstrated by the few incorrect noncanonical/malleable annotations that were necessary to make this work).

I have some ideas about how to bring back an actual don't-care-about-malleability satisfier in a more testable way, but that can wait until after integration in Bitcoin Core.

darosior commented 2 years ago

Had to rebase on top of #101, so if you need to rebase: https://github.com/darosior/miniscript/tree/202202_unify_sat

sipa commented 2 years ago

Rebased on merged #101, and addressed comments.