Skip to content

Backports BIP-388 WalletPolicy support to release-13.x - #1009

Open
trevarj wants to merge 7 commits into
rust-bitcoin:release-13.xfrom
trevarj:13.x/wallet-policy
Open

Backports BIP-388 WalletPolicy support to release-13.x#1009
trevarj wants to merge 7 commits into
rust-bitcoin:release-13.xfrom
trevarj:13.x/wallet-policy

Conversation

@trevarj

@trevarj trevarj commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Backports PRs by cherry-picking all commits:

For supporting external issue bhwi #68 to move from git commit pinning to a released crate.

trevarj and others added 7 commits July 26, 2026 07:04
- Instead of accepting a closure to convert the Key type to a String, added type
bounds to use Key: FromStr.
- Added new error type XKeyParseError, which will be a wrapper for the error
type on a Key's FromStr. XKeyParseError must implement From from that type.
- Change visibility of parse_xkey_deriv to pub(crate) for later usage.
- two new derivation_path functions, `derivation_path` and `derivation_paths`
that omit the path origin
- a `wildcard` accessor function to get the Wildcard value
Implemented BIP-388 by introducing a new type, `WalletPolicy`, which can be used
to create descriptor templates.

The idea is pretty simple and only really required making a new type that
implements `MiniscriptKey`, then the existing parser and `Translator` trait
takes care of the rest.

There are a few edge cases that require validation, which isn't so nice, but
works for now. Test cases that require BIP-390 and BIP-387's sortedmulti_a are
commented out and issues could arise with those test vectors when/if those BIPs
are implemented.

See `WalletPolicy`'s doc and the unit tests for usage.
…ceholders

set_key_info() counted key-expression occurrences instead of unique
placeholder indices. A template reusing @0 with disjoint paths (e.g.
@0/**,@0/<2;3>/*) would accept 2 keys but silently drop the second
during descriptor translation, since both @0 resolve to key_info[0].

Reported by jm@squareup.com
- translate all four hash terminal types between key representations
- report invalid hash hex and cover descriptor round trips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants