Support for Miniscript and Output Descriptors for rust-bitcoin
  • Rust 99.4%
  • Shell 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Andrew Poelstra 5a5f7494ce
Merge rust-bitcoin/rust-miniscript#1040: fix(miniscript): count exactly k satisfactions in thresh max-size bounds
d7801d1405 fix(miniscript): count exactly k satisfactions in thresh max-size bounds (russeree)

Pull request description:

  A `thresh(k, ...)` witness satisfies exactly k children: the script checks
  the running sum against k with `OP_EQUAL`, so any witness with a different
  number of satisfied children is invalid. The maximum-satisfaction
  computation in `ExtData::threshold` nevertheless selected k+1 children as
  satisfied (`i <= k` instead of `i < k`), e.g. computing the maximum witness
  size of `thresh(1,pk(A),s:pk(B))` as 146 bytes (two signatures) instead of
  74 (one signature plus one empty dissatisfaction).
  
  This inflates `Miniscript::max_satisfaction_weight()` and everything
  derived from it, making fee/weight estimates overestimate by up to one
  largest-child satisfaction per thresh node.
  
  Found by differential testing against Bitcoin Core's miniscript
  implementation (`Node::GetWitnessSize`/`GetStackSize` agree with the fixed
  values, and with the reference implementation's satisfaction table,
  which permits exactly k satisfactions).


ACKs for top commit:
  apoelstra:
    ACK d7801d1405; successfully ran local tests


Tree-SHA512: 6b4a96f1d6fe27794d38c53b605630571a3333a9645ef7faf31014c67b2a693e4c72a02d321437938d121eab9bda86c4ea646ab2c5daa1cfd03dbac798b39f55
2026-09-04 17:46:55 +00:00
.github ci: prevent rbmt disk fill with logs 2026-07-22 17:37:57 -03:00
bitcoind-tests chore: migrate rbmt config to cargo metadata 2026-06-08 07:24:13 +00:00
contrib ci: add taptree_of_horror to list of examples to run 2025-03-31 12:22:07 +00:00
doc doc/compiler.md:fix taproot_compiler.pdf link 2023-11-02 15:03:08 -04:00
embedded remove all sanity_check and ext_check methods from the library 2026-05-21 13:05:18 +00:00
examples feat(policy): math notation for semantic::Policy (Display + Parser) 2026-07-20 10:58:15 +09:00
fuzz feat(policy): math notation for semantic::Policy (Display + Parser) 2026-07-20 10:58:15 +09:00
src Merge rust-bitcoin/rust-miniscript#1040: fix(miniscript): count exactly k satisfactions in thresh max-size bounds 2026-09-04 17:46:55 +00:00
tests use hex-conservative 1.0 everywhere for decoding 2025-07-16 13:19:34 +00:00
.gitignore .gitignore:*.DS_Store 2023-11-02 15:47:26 -04:00
AGENTS.md copy AGENTS.md, CLAUDE.md, CONTRIBUTING.md and SECURITY.md from rust-bitcoin 2026-05-25 13:04:04 +00:00
Cargo-minimal.lock chore(deps): bump bitcoin to 0.32.6 2025-09-08 10:52:49 +10:00
Cargo-recent.lock chore(deps): bump bitcoin to 0.32.6 2025-09-08 10:52:49 +10:00
Cargo.toml Automated update to rustc nightly-2026-08-21 2026-08-24 20:25:51 -03:00
CHANGELOG.md docs: add v13.1.0 CHANGELOG entry 2026-06-09 18:10:15 -03:00
CLAUDE.md copy AGENTS.md, CLAUDE.md, CONTRIBUTING.md and SECURITY.md from rust-bitcoin 2026-05-25 13:04:04 +00:00
CONTRIBUTING.md copy AGENTS.md, CLAUDE.md, CONTRIBUTING.md and SECURITY.md from rust-bitcoin 2026-05-25 13:04:04 +00:00
justfile ci: add rbmt setup and update weekly rust nightly bump 2026-06-08 11:06:50 +03:00
LICENSE add LICENSE, fields that crates wants 2018-11-13 19:35:02 +00:00
rbmt-version Automated update to cargo-rbmt-0.5.3 2026-08-29 06:59:53 +00:00
README.md docs: link ANTLR4 Miniscript grammar 2026-07-27 17:48:43 +06:00
rustfmt.toml Update deprecated field in rustfmt.toml 2024-11-10 14:08:54 +01:00
SECURITY.md copy AGENTS.md, CLAUDE.md, CONTRIBUTING.md and SECURITY.md from rust-bitcoin 2026-05-25 13:04:04 +00:00

Stars Forks Contributors Build Issues

Minimum Supported Rust Version: 1.63.0

Miniscript

Library for handling Miniscript, which is a subset of Bitcoin Script designed to support simple and general tooling. Miniscripts represent threshold circuits of spending conditions, and can therefore be easily visualized or serialized as human-readable strings.

High-Level Features

This library supports

  • Output descriptors including embedded Miniscripts
  • Parsing and serializing descriptors to a human-readable string format
  • Compilation of abstract spending policies to Miniscript (enabled by the compiler flag)
  • Semantic analysis of Miniscripts and spending policies, with user-defined public key types
  • Encoding and decoding Miniscript as Bitcoin Script, given key types that are convertible to bitcoin::PublicKey
  • Determining satisfiability, and optimal witnesses, for a given descriptor; completing an unsigned bitcoin::TxIn with appropriate data
  • Determining the specific keys, hash preimages and timelocks used to spend coins in a given Bitcoin transaction
  • no_std support enabled by disabling the default-features. See embedded/ for an example.

More information can be found in the documentation or in the examples/ directory

Minimum Supported Rust Version (MSRV)

This library should always compile with any combination of features on Rust 1.63.0.

Some dependencies do not play nicely with our MSRV, if you are running the tests you may need to pin some dependencies. See ./contrib/pin.sh for current pinning.

Contributing

Contributions are generally welcome. If you intend to make larger changes please discuss them in an issue before PRing them to avoid duplicate work and architectural mismatches. If you have any questions or ideas you want to discuss please join us in ##miniscript on Libera.

Benchmarks

We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the benchmarks use: RUSTFLAGS='--cfg=bench' cargo +nightly bench benchmarks.

Other Resources

An ANTLR4 grammar for Miniscript expressions is available in the ANTLR grammars-v4 repository.

Release Notes

See CHANGELOG.md.

Licensing

The code in this project is licensed under the Creative Commons CC0 1.0 Universal license. We use the SPDX license list and SPDX IDs.