Miniscript: writing policies instead of raw Script
Bitcoin Script is a stack-based language capable of expressing rich spending conditions, multisig, timelocks, hash preimages, and combinations of all three. But hand-writing raw Script is genuinely risky: it's easy to construct a script that looks correct but has a subtle logic error, and because Script isn't generally analyzable, that error might only surface when someone tries to spend funds and fails, or worse, when funds are stolen through an unintended spending path. Miniscript solves this by giving you a structured, compositional language for expressing policies, like 'either 2 of these 3 keys, or 1 key after a 6-month timelock,' that compiles down to safe, provably correct Script.
The key property is analyzability. Because Miniscript expressions are built from a small set of well-understood fragments, tools can statically determine things like the maximum witness size, whether a policy is satisfiable at all, and how many ways a given output can be spent. This is exactly why BDK descriptors lean on Miniscript under the hood for anything beyond simple single-sig, it turns 'trust that this hand-rolled Script is correct' into 'compile from a policy whose properties are checked before it ever touches a real UTXO.'
