Replies: 1 comment 2 replies
-
Ok, after sleeping on this I have a much better idea. I propose that we effectively merge #[non_exhaustive]
pub struct ValidationParams {
pub allow_duplicated_pubkeys: bool,
pub allow_xonly_pubkeys: bool,
pub allow_standard_pubkeys: bool,
pub allow_uncompressed_pubkeys; bool,
pub max_script_size: usize,
...
} This structure would represent a monotonic set of constraints. Unlike Then we would have a set of constants representing the current script contexts. So The rules would be:
I believe we can implement this in an easy-to-write/review way by starting with a copy of The result will be a cleaner, easier to understand, and more flexible API (e.g. it will let users set script size limits lower than any of the consensus limits, if they want). And it should have much smaller codegen since we aren't parameterizing every little thing by |
Beta Was this translation helpful? Give feedback.
-
It has been a long-term goal to eliminate the
Ctx
parameter and move it to adyn ScriptContext
or an enum or some sort of runtime-checked object. The reasoning is that we only need the context object "at the edges" of the API and having to thread it through pretty-much the entire codebase is exhausting and probably partly responsible for how large the codebase is.However, I'm unsure how feasible it is to actually eliminate it. The context object is used:
multi
ormulti_a
is active and the byte length of keysDescriptorPublicKey
et al should be encoded as normal keys or xonly ones)It's really the first point where we have trouble, because we want to be able to use the
core::str::FromStr
trait. However, this trait does not have any way to provide a context object other than as a type parameter. So if you try to parse a Miniscript that looks likec:pk_k(<xonly key>)
it's really not clear how the user should indicate whether this is a Taproot script (okay) or a legacy one (not okay).One thought is that we could split the
Miniscript<Pk, Ctx>
type into aMiniscript<Pk>
type that does no validation and aValidated<Miniscript<Pk>, Ctx>
type which does validation on construction. Then ourDescriptor
enum would containValidated
objects rather than directly containingMiniscript
objects.Then the unvalidated
Miniscript<Pk>
object could be parsed from a string or a script, re-serialized as a string, and typechecked (which includes a few useful things like checking for safeness, timelock mixing, malleability, etc), but not lifted or converted to a script. You would need to validate it to put it into a descriptor, encode it to script, lift it. In principle this would be a big breaking change, but I think that in practice very few people are using theMiniscript
type directly. Looking at the docs for the type it seems to have a limited and ad-hoc API, and ideally everybody would be usingDescriptor
instead, which wouldn't substantially change. Especially if theValidated
type implementedDeref
to the underlyingMiniscript
.Beta Was this translation helpful? Give feedback.
All reactions