A WebAssembly Miniscript Studio that runs entirely in the browser, powered by the Rust Miniscript crate. Compile Bitcoin policies to Miniscript and Bitcoin Script, lift scripts, generate addresses across Legacy, Segwit, and Taproot contexts, HD wallet descriptor support, key managment, educational examples and more.
π Live Site: https://adys.dev/miniscript
- Policy Editor: Write spending conditions with syntax highlighting and auto-compilation
- Miniscript Editor: Work with raw miniscript or compile from policies
- Lift: Convert back Bitcoin Script β Miniscript β Policy
- Taproot Support: Full support with branch selection and script path analysis
- HD Wallet Descriptors: Range descriptors with index field and multipath support
- Spending Analysis: Detailed cost analysis and satisfaction paths
- Context Switching: Legacy, Segwit v0, and Taproot with automatic detection
- Address Generation: Bitcoin addresses with mainnet/testnet toggle
- Key Management: Auto-extract, generate, and manage key variables
- Save & Share: Local storage and shareable URLs
- Rich Examples: 20+ examples with educational descriptions
- Local-First: All data stays in your browser - no server required
- Write high-level spending conditions with syntax highlighting
- Auto-compilation on load (configurable)
- Example descriptions (collapsible in settings)
- Indent expressions for readability
- Auto-clean invalid characters before compiling
- Works standalone or with Policy editor
- Detailed compilation messages with spending analysis
- Branch selection for Taproot OR conditions
- Shows satisfaction paths and weight units
- Load examples with rich educational descriptions
- Bitcoin Script in HEX and ASM formats
- Editable fields for lifting operations
- Bitcoin addresses with network toggle (mainnet/testnet)
- Show/hide pushbytes operations
- Show/hide key names to see actual values
Manage public keys with friendly names:
- Missing variables: Write
or(pk(Nadav),pk(Aviv))β auto-generate keys for undefined variables - Hex to variables: Convert long hex keys to named variables automatically
- From errors: Generate missing keys directly from error messages
- Add/Edit/Delete: Full control over key variables
- Generate: π² creates context-appropriate test keys
- Toggle Display: Show names or actual key values
- Restore Defaults: Reset to default keys anytime
- Key Types: Compressed (66 chars) for Legacy/Segwit, X-only (64 chars) for Taproot
- Local Storage: Keys saved in browser, never sent to server
The Script HEX and ASM fields are editable - paste any Bitcoin Script to reverse it:
- Input: Paste hex or ASM format into the editable script fields
- Output: Automatically lifts to readable miniscript
- Input: Any miniscript expression
- Output: High-level policy representation
Note: Not all scripts can be lifted (e.g., scripts with public key hashes)
- Legacy (P2SH): Traditional Bitcoin scripts, max compatibility
- Segwit v0 (P2WSH): Native witness scripts, lower fees
- Taproot: Privacy-enhanced scripts with multiple sub-contexts:
- Single Leaf / key: A single script leaf, or key only when no script
- Script Path: Multiple branches with cost analysis
- Script + Key Path: Combined key and script spending paths
- OR Conditions: Choose which branch to compile from policy
- Script Paths: Visualize different spending paths with costs
- Weight Units: Fee estimation for each path
- Satisfaction Paths: All ways to spend the script
- Descriptors: Full taproot descriptor display
- Cost Comparison: Compare different contexts
Full support for xpub/tpub descriptors with range patterns:
- Auto-appears: When using wildcard patterns (
/*) - Index input: Enter 0-2147483647 for specific derivations
- No expression editing: Change index without modifying the descriptor
- Range descriptors:
<0;1>/*for external/change branches - Path selector: Dropdown to choose External or Change
- BIP389 Compliant: Modern HD wallet patterns
- All contexts: Works in Legacy, Segwit, and Taproot
Persistent local storage for your work:
- Save Policies: πΎ button stores policy expressions (up to 20)
- Save Expressions: πΎ button stores compiled miniscript (up to 20)
- Load: Click "Load" to restore saved items with context preserved
- Local Storage: All data stays in your browser
- Export: π button copies expressions to clipboard
Create shareable URLs for collaboration:
- Create Link: π button generates shareable URL
- Formats: URL encoded (
?policy=...) or compact JSON (?state=...) - Auto-load: Links automatically load expressions when opened
- π¨ Theme: Dark/Light mode switcher
- π Auto-compile: Automatically compile when loading examples or saved expressions
- π Show descriptions: Display helpful descriptions for example buttons
- π‘ Editor tips: Show/hide helpful placeholder text in empty editors
- π Share format: Choose between URL encoded or JSON format for share links
- ποΈ Hide corner buttons: Hide GitHub and donation buttons (web only)
- π³ Tree display: Script Compilation, Visual Hierarchy, or Hidden
- Rust (latest stable version)
wasm-packfor building WebAssembly modules
# Install wasm-pack if not already installed
cargo install wasm-pack
# Build the WebAssembly module
wasm-pack build --target web
# Serve the application (WebAssembly requires HTTP server)
python -m http.server 8000
# Then open http://localhost:8000 in your browserminiscript-compiler/
βββ miniscript/
β βββ index.html # Main web interface
β βββ script.js # Entry point, imports modules
β βββ modules/
β β βββ compiler-core.js # MiniscriptCompiler class
β β βββ window-functions.js # Global window functions
β β βββ constants.js # Shared constants
β βββ pkg/ # Generated WASM bindings
βββ src/
β βββ lib.rs # WASM exports
β βββ compile/ # Compilation logic
β βββ descriptors/ # HD wallet descriptors
β βββ taproot/ # Taproot-specific logic
β βββ lift/ # Script lifting
β βββ keys/ # Key management
β βββ address/ # Address generation
β βββ validation/ # Input validation
βββ tests/ # Rust tests
βββ Cargo.toml # Rust dependencies
βββ README.md # This file
miniscript- Bitcoin miniscript librarybitcoin- Bitcoin protocol implementationwasm-bindgen- WebAssembly bindingsserde- Serialization framework
This project is licensed under the MIT License. See the LICENSE file for details.