To perform a transaction, your wallet uses established scripts or OP_CODES native to the bitcoin network. A simple transfer of bitcoin from one bitcoin user to another will contain specific scripts, while a more complex transaction like a muti-sig wallet would require a different set of scripts. For most of us, the bitcoin wallet would abstract these commands from the process, so users need not deal with the complexity of the script. Still, for power users like exchanges, software wallet developers, bitcoin businesses and signing device manufacturers, these scripts are an important part of building on bitcoin and creating a robust and smooth experience.
A script: is a list of instructions accepted by the bitcoin network and recorded with each transaction that describes how the next person wanting to spend the bitcoin being transferred can gain access to them.
Miniscript is a standardisation of bitcoin scripts; think of it as turning each script into a building block that any bitcoin wallet could use as a method of compiling transactions on the back end based on what the user would like to achieve. Minscript allows the software to automatically analyse a script, including determining what witness data must be generated to spend bitcoins protected by that script. It saves wallet developers time as they don’t need to write new code when they switch from one script template to another and would provide better interoperability for users switching between wallets.
How miniscript work Miniscript is a language for writing (a subset of) Bitcoin Scripts in a structured way, enabling analysis, composition, generic signing and more. Bitcoin Script is an unusual stack-based language with many edge cases, designed for implementing spending conditions consisting of various combinations of signatures, hash locks and time locks. Yet despite being limited in functionality, it is still highly nontrivial to: Given a combination of spending conditions, finding the most economical script to implement it.
Given two scripts, construct a script that implements a composition of their spending conditions (e.g. a multi-sig where one of the “keys” is another multi-sig).
Given a script, find out what spending conditions it permits.
Given a script and access to a sufficient set of private keys, construct a general satisfying witness for it.
Given a script, be able to predict the cost of spending an output.
Given a script, know whether particular resource limitations like the ops limit might be hit when spending.
Miniscript functions as a representation for scripts that makes these sorts of operations possible. It has a structure that allows composition. It is very easy to statically analyse for various properties (spending conditions, correctness, security properties and malleability).
It can be targeted by spending policy compilers (see below). Finally, compatible scripts can easily be converted to Miniscript form – avoiding the need for additional metadata for e.g. signing devices that support it.
For now, Miniscript is really only designed for P2WSH and P2SH-P2WSH embedded scripts. Most of its constructions work fine in P2SH, but some of the (optional) security properties rely on Segwit-specific rules. Furthermore, the implemented policy compilers assume a Segwit-specific cost model.
reply