Commit 9320f36
committed
miniscript: introduce ValidationParams type
This introduces the ValidationParams type but does not use it anywhere.
As you can see, this is a composite of the checks in ExtParams and the
checks in miniscript::analyzable and the checks in miniscript::context.
In this commit we add a few associated constants to ValidationParams:
* MAX means "allow the maximum amount of stuff" and literally just turns
off every single validation check. This is rarely useful by itself but
it is frequently useful to say "do this one check" by constructing a
ValidationParams with that check turned on and `..MAX` for everything
else. The struct is #[non_exhaustive] so users cannot construct it
without doing something like this.
* (There is no MIN because I can't think of a use for it.)
* CONSENSUS is MAX except enables the rules that are enforced by consensus
across all contexts. Previously we used the term "insane" for this.
* SANE is CONSENSUS with additional policy limits and Miniscript-specific
rules, e.g. banning duplicate public keys.
**One important change:** our CONSENSUS constant is going to replace all
usage of "insane", but CONSENSUS allows raw pkhs while "insane" did not.
It's hard for me to imagine a case where somebody would even notice this,
but I'm highlighting it because it's an intentional change to try to make
our validation rulesets match their names better. My feeling is that
"consensus" means "handle anything allowed by consensus", including
extensions like rawpkhs that exist only in rust-miniscript.
In the next commit, we will add MAX/CONSENSUS/SANE associated constants
to each context object, by starting with the global ones and then turning
on the additional rules that apply to each context.
The eventual goal is that we remove the existing analyzable/ExtParams/Ctx
stuff, drop Ctx as a type parameter on the Miniscript type, and then the
Ctx trait becomes basically a nice way to access constants.
I am keeping the term "sane" throughout these PRs, though a better term
might be "default", since the sane rules are the ones that you get if you
use the "normal" parse/decode/from_str methods. We can do this once the
dust settles a bit.
A natural question, if you are familiar with the codebase, is "why bring
in a new struct instead of just extending ExtParams". Well, I could have,
but I hate the name of the struct and the names of all the fields. And
since I'm causing a lot of API breakage I might as well take the
opportunity to improve the naming.1 parent 38cef7c commit 9320f36
2 files changed
Lines changed: 411 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
492 | 494 | | |
493 | 495 | | |
494 | 496 | | |
| 497 | + | |
| 498 | + | |
495 | 499 | | |
496 | 500 | | |
497 | 501 | | |
| |||
547 | 551 | | |
548 | 552 | | |
549 | 553 | | |
| 554 | + | |
550 | 555 | | |
551 | 556 | | |
552 | 557 | | |
| |||
588 | 593 | | |
589 | 594 | | |
590 | 595 | | |
| 596 | + | |
591 | 597 | | |
592 | 598 | | |
593 | 599 | | |
| |||
0 commit comments