Miniscript
Miniscript is a language for writing a structured subset of Bitcoin Script. A Miniscript expression compiles to Script, can be analyzed for correctness, size, and satisfaction, and can be composed from smaller expressions. It is used with output descriptors, typically inside wsh() or tr(), so wallets can import a spending policy rather than a raw script hex blob.
Arbitrary Script is hard to analyze: it is not obvious whether a script is spendable, whether two scripts encode the same policy, what witness is required, or whether a proposed satisfaction is minimal. Wallets that implement multisignature or timelocked recovery therefore tend to hard-code a few templates. Pieter Wuille, Andrew Poelstra, and Sanket Kanjalkar designed Miniscript as a composition-friendly representation of the Script subset used for spending policies. A higher-level policy language describes thresholds, keys, hashes, and timelocks; Miniscript itself is closer to Script and carries type information for correct compilation.
A policy such as “two of these three keys, or one key after a relative delay” is written in a functional notation and compiled to Miniscript, then to Script. Fragments include pk_k, pk_h, older, after, sha256, hash256, and_v, or_b, thresh, and others. Each fragment has a type and properties that describe malleability, whether it can be satisfied without a signature, and how large the script and witness will be. Type checking rejects compositions that leave the stack wrong or that are malleable under standard rules. Given available secrets, a satisfier can construct a witness. These properties let a wallet predict fees, detect incomplete PSBTs, and refuse a satisfaction another party could later mutate.
Miniscript does not cover every Script opcode. It targets standard P2WSH and Tapscript spending under Segregated Witness and Taproot. Some valid scripts have no Miniscript form. Compilers try to choose a small, non-malleable representation. In descriptors, Miniscript appears as the argument to wsh() or as leaves of tr(), with key expressions following BIP380 (including origin fingerprints and BIP32 paths). A descriptor checksum covers the whole string so a policy can be backed up as text.