Skip to content

Add support for sortedmulti_a#910

Open
trevarj wants to merge 1 commit intorust-bitcoin:masterfrom
trevarj:support-sortedmulti_a
Open

Add support for sortedmulti_a#910
trevarj wants to merge 1 commit intorust-bitcoin:masterfrom
trevarj:support-sortedmulti_a

Conversation

@trevarj
Copy link
Contributor

@trevarj trevarj commented Mar 22, 2026

Support sortedmulti_a at the top-level of taproot descriptors, which is mostly
identical to multi_a, except that the x-only pubkeys are sorted upon encoding
into Bitcoin Script.


I think the previous attempts at adding sortedmulti_a were prior to the parser
rewrite. With the current parser it seems to me that sortedmulti_a is basically
a copy and paste of multi_a with the key sorting added.

The sorting is done upon encode()ing of the Miniscript, just as BIP 387 describes.

I'm a little suspicious on if the unit and integration tests are effective for
sortedmulti_a, so I'd like to have some extra eyes/feedback on that. It might be
better to add an integration test that can match against what Core produces on a
round trip from Descriptor to Address at least.

Resolves #320

@trevarj trevarj force-pushed the support-sortedmulti_a branch from 3b7ed1f to ff5c979 Compare March 22, 2026 12:37
Support sortedmulti_a at the top-level of taproot descriptors, which is mostly
identical to multi_a, except that the x-only pubkeys are sorted upon encoding
into Bitcoin Script.
@trevarj trevarj force-pushed the support-sortedmulti_a branch from ff5c979 to e62cb50 Compare March 22, 2026 12:45
let thresh = Threshold::new(k as usize, keys).map_err(Error::Threshold)?;
term.push(Miniscript::multi_a(thresh));
if thresh.is_sorted() {
term.push(Miniscript::sortedmulti_a(thresh));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second guessing this...do I need to check if keys.len() == k && thresh.is_sorted() and then that will decode as a sortedmulti_a?

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.

Support for sortedmulti_a

1 participant