Add Output Descriptor library#2568
Open
guggero wants to merge 5 commits into
Open
Conversation
Collaborator
Collaborator
Author
Yeah, it's a junky boyyy... A lot of the added lines are test vectors. But lots of Go code as well, I agree. |
This commit adds a fully-featured miniscript implementation that is modeled after the rust-bitcoin/rust-miniscript repository. The miniscript functionality is equivalent to the rust-miniscript implementation at version 13.1.0 and all test vectors (introduced in the next commit) are extracted from the Rust reference implementation to ensure full compatibility and feature-completeness. Co-authored-by: Oli <gugger@gmail.com>
This commit adds test vectors taken from https://github.com/rust-bitcoin/rust-miniscript/blob/59ad2ed/src/miniscript/ms_tests.rs to the miniscript implementation. Co-authored-by: Oli <gugger@gmail.com>
This commit adds descriptor parsing, checksum calculation and validation and several methods to the Descriptor struct: - AddressAt() - Keys() - DescType() - MaxWeightToSatisfy() - MultipathLen() - ScriptCodeAt() - String()
This commit adds the Lift() and PlanAt() methods to the Descriptor struct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

I wasn't able to reopen the old PR, so I'm resurrecting it here.
After using https://github.com/benma/descriptors-go in a mobile project, the limitations of using a WASM interpreter showed to be too restricting. So I'm giving it another try, this time with quite a bit of agentic help (I gave up on #1987 because I'm not smart enough for compiler-level stuff, but apparently Claude is quite capable).
Description
Adds a
miniscriptlibrary (originally authored by @benma in https://github.com/benma/miniscript-go) and then adds full Output Descriptor support on top.The code is modeled after the
rust-miniscriptimplementation and a lot of test vectors for diferential unit tests were extracted from that implementation.The
miniscriptfeature set should be equivalent withrust-miniscript 13.1.0. Thedescriptorsfeatures are currently limited to feature parity with https://github.com/benma/descriptors-go.Implementation disclaimer
The code in this PR is more or less a supervised re-implementation of
rust-miniscript. I spent a lot of tokens on differential code review and bug hunting, including large amounts of test vectors extracted from the original Rust code.There are also seeded fuzz tests that have been running for several hours on a 12-core machine.
All commits are hand-crafted and conform to the repository's code style. But apart from that, the code is not mine (I'd guess about 60% original miniscript code by @benma and the rest added by Claude Opus 4.8).