---
title: "Miniscript Policy — definition | Nuri Glossary"
description: "A readable description of spending conditions that compiles down to Miniscript and then Script."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/miniscript-policy"
---

# Miniscript Policy

A readable description of spending conditions that compiles down to Miniscript and then Script.

## Basically

Miniscript policy lets you write rules for spending Bitcoin in a form people can read. A compiler turns those rules into the instructions Bitcoin uses.

## Key Takeaways

- Miniscript policy uses simple primitives such as pk, and, or, and thresh to describe Bitcoin spending conditions. It sits above Miniscript and Bitcoin Script in a three-layer stack.
- A compiler turns policy expressions into the most efficient Miniscript representation. Miniscript then maps deterministically to raw Bitcoin Script opcodes, so you do not need to optimise Script manually.
- Policy works with output descriptors and descriptor wallets. This creates portable, analysable wallet configurations that multiple software implementations can import and verify.

## What Is Miniscript Policy?

Miniscript policy is a high-level language for Bitcoin spending conditions that people can read and reason about. You describe your intent with composable primitives instead of writing raw Bitcoin Script opcodes: "require two of these three keys," "allow a backup key after 90 days," or "need both a signature and a hash preimage." A compiler then turns that intent into optimised Script.
Pieter Wuille, Andrew Poelstra, and Sanket Kanjalkar developed the policy language alongside Miniscript. Miniscript is a structured, well-specified subset of Bitcoin Script made for analysis and composition, while policy sits one layer above it as a developer-facing tool. Policy records what you want to enforce, and Miniscript and Script handle how it is enforced on-chain.

## How It Works

Miniscript policy uses a three-layer compilation stack. Each layer has a distinct purpose, and the clear boundaries between them make the system useful.

## Policy Primitives

The policy language provides a small set of composable building blocks:
These primitives compose freely. You can nest any sub-policy inside any combinator to build arbitrarily complex spending conditions from simple, well-understood parts.

## The Compilation Process

A single policy can often have multiple valid Miniscript representations. Each one produces different Bitcoin Script with different size and cost characteristics, so the compiler looks for the most efficient encoding automatically.
A vault policy might let two partners sign together normally, but let either partner spend alone after a 90-day timeout:
The compiler evaluates different Miniscript representations for this policy. It considers script size, witness size, and which spending paths are more likely. Developers can supply probability hints using a weight prefix:
These weights guide the compiler to put the more likely spending path in the cheaper position within the resulting Script. The compiler also chooses between OP_IF / OP_ELSE orderings, selects optimal Miniscript wrapper types, and minimises witness sizes for common cases.

## Policy Is Not Deterministic

Policy-to-Miniscript compilation is not guaranteed to be deterministic. The same policy expression may produce different Miniscript across compiler versions, implementations, or even platforms, so you should not use policy as a canonical representation for sharing wallet configurations.
Miniscript-to-Script mapping is fully deterministic by contrast. One Miniscript expression always produces exactly one Bitcoin Script, which is why output descriptors reference the compiled Miniscript or Script rather than the original policy.

## Descriptor and Wallet Integration

Miniscript policy connects to the broader Bitcoin wallet ecosystem through output descriptors. After you compile a policy to Miniscript, you can wrap the result in a descriptor like wsh(...) for P2WSH outputs or use it inside a Tapscript leaf for P2TR outputs.
A compiled 2-of-3 policy might produce this descriptor:
Bitcoin Core has progressively added Miniscript support to its descriptor wallet implementation. Watch-only support arrived in version 24.0, signing support for P2WSH descriptors in 25.0, and Tapscript support in version 26.0. Hardware wallets including Ledger have also added Miniscript signing support, so you can import complex spending policies onto signing devices.

## Multi-Party Custody

Policy makes it straightforward to express complex custody arrangements beyond simple k-of-n multisig. A corporate treasury might use:
Raw Script would require deep knowledge of opcode interactions, stack manipulation, and witness structure without the policy language. The policy compiler handles all of that.

## Inheritance Planning

Time-decaying security policies fit the policy language naturally. An inheritance scheme might start with full owner control and progressively relax requirements as time passes:

## Escrow and Conditional Payments

Key requirements combined with hash locks enable trustless escrow patterns. A buyer and seller can agree on a policy where either both sign to release funds, or an arbitrator resolves disputes:

## Collaborative Wallet Recovery

Policy integrates naturally with social recovery schemes. A wallet might normally require the owner's key, but allow a threshold of trusted contacts to recover funds after a delay. A single policy expression can describe all of this and compile to a single Script.

## Available Tools

Several tools and libraries support Miniscript policy compilation:

## Compiler Output Variability

Policy-to-Miniscript compilation is not deterministic, so the same policy may compile to different Scripts across tools or versions. Wallet developers should store and share the compiled Miniscript or descriptor, not the source policy. Using policy as the canonical representation risks generating incompatible addresses across different software.

## Script Size Limits

Complex policies can produce large Scripts that approach or exceed Bitcoin's consensus limits. For P2WSH outputs, the witness script cannot exceed 10,000 bytes, and the overall number of opcodes is capped at 201. Taproot relaxes some of these limits through Tapscript, which removes the opcode limit and allows complex policies to be split across multiple Taptree leaves.

## Analysis Assumptions

The policy compiler optimises using probability weights supplied by developers. Actual spending patterns that differ significantly from these weights may put the most-used spending path in a more expensive position. Correctness is unaffected, but transaction fees can increase for common operations.

## Limited Expressiveness

The policy language deliberately limits what you can express. It cannot encode every possible Bitcoin Script program, only those within Miniscript's structured subset. Introspecting transaction amounts or accessing stack values in arbitrary ways is outside its scope. These constraints are a deliberate tradeoff that enables the static analysis and optimisation that make the system valuable.
The research article on Miniscript spending policies and the Bitcoin Script programmability overview offer a deeper technical exploration of composable spending conditions.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
