MiniscriptJS is a library designed for ease of use and extensibility. It is a work in progress and should not be used outside experimentation purposes.
Open ts-node
and enter the following:
let rootExpression = Miniscript.parse("thresh(1,pk(0xA),s:pk(0xB))");
console.log(rootExpression.toScript());
This should output the human-readable script ASM for the given Miniscript expression.
More examples can be found here
Miniscript is a language designed by Pieter Wuille, Andrew Poelstra, and Sanket Kanjalkar. It enhances the simplicity, composability, and verifiability of Bitcoin Script creation. The essence of Miniscript lies in its ability to facilitate semantic reasoning about script correctness, minimize script malleability, and promote composability.
One of Miniscript's core strengths is its bidirectional compatibility with Bitcoin Script: every Miniscript expression can be directly compiled to a Bitcoin Script, and vice versa, allowing for seamless interchangeability between the two.
Miniscript also introduces a policy language that simplifies scripting by abstracting common patterns into more straightforward expressions. For instance, specific operations like 'and_v' and 'and_b' are consolidated into a single 'and' operation in the policy language, making scripts more accessible and less error-prone to write. It also adds a syntax for encoding probabilities into subexpressions for which it accordingly picks the best Miniscript representation of. Currently, MiniscriptJS does not support the policy language, but future updates may include this feature.
We welcome contributions from the community! Whether you're interested in fixing bugs, adding new features, or improving documentation, your help is invaluable to making MiniscriptJS better for everyone.
MiniscriptJS is licensed under MIT License. Feel free to use, modify, and distribute the code according to the license agreement.