THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Miniscript Explained: Spending Policies, Satisfaction, and Analysis

permalink THAMER
#bip379#bitcoin#miniscript#multisig#policy#timelocks

Miniscript is a structured language for expressing and analyzing Bitcoin Script spending conditions. It helps wallet and tooling developers reason about complex scripts, including multisignature authorization, timelocks, and recovery branches. Miniscript is not a new Bitcoin consensus system: the resulting scripts must still obey the existing consensus rules for the relevant output type.

Policy versus script

A human-oriented spending policy might say: two authorized keys can spend immediately, or one recovery key can spend after a relative delay. The policy describes intent. A Miniscript expression describes an executable script structure with defined typing and satisfaction rules. A compiler can transform supported policies into Miniscript, but not every arbitrary policy maps to every script context.

For example, older(144) expresses a relative timelock requirement in suitable contexts, while key-check fragments express signature requirements. A real script must also satisfy the transaction's sequence and version constraints where applicable. An example fragment is not automatically a complete wallet descriptor or safe production policy.

Satisfaction and dissatisfaction

Miniscript analysis determines how an output can be satisfied: which signatures, preimages, or timelock conditions must be provided to spend it. This enables tools to estimate witness size, choose a viable spending path, and identify some non-malleability or resource issues before funds are deposited.

A spending path can be available under one set of chain conditions and unavailable under another. For a relative timelock, the age of the specific UTXO matters; for an absolute timelock, block height or time constraints matter. Wallets must coordinate signatures and transaction fields consistently with the selected branch.

Why developers use Miniscript

Without a structured policy language, manually assembled Script can be hard to review and may hide unintended paths. Miniscript makes supported scripts easier to inspect and reason about. It also helps coordinate PSBT construction, fee estimation, and backup documentation for multisigner wallets.

Miniscript does not remove key-management risks, guarantee that all participants will cooperate, or automatically protect against an unsafe policy. A policy that allows one compromised recovery key to spend after a delay still has that exact risk.

Script context matters

Miniscript's original specification targets SegWit v0 P2WSH. Tapscript has different signature rules and a related but distinct Miniscript specification. Tools must use the right script context and not assume a v0 witness script is interchangeable with a Taproot script leaf.

Primary references

BIP379 — Miniscript: https://github.com/bitcoin/bips/blob/master/bip-0379.mediawiki

BIP342 — Validation of Taproot Scripts: https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki

Bitcoin Core Miniscript documentation: https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects