Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Descriptor updates #370

Merged
merged 18 commits into from
Apr 3, 2023
Merged

WIP: Descriptor updates #370

merged 18 commits into from
Apr 3, 2023

Conversation

jgriffiths
Copy link
Contributor

@jgriffiths jgriffiths commented Feb 20, 2023

Adds more introspection information and support for multi-path descriptors.

This allows iteration/generation of all available possible scripts/addresses without knowing anything about a descriptor up-front.

cc: @Sjors @k-matsuzawa

@Sjors
Copy link
Contributor

Sjors commented Mar 16, 2023

I did some light testing in Sjors/libwally-swift#86 to see if the WALLY_MS_IS_DESCRIPTOR works.

@jgriffiths jgriffiths force-pushed the descriptor_updates branch 2 times, most recently from 5314425 to 5650ac2 Compare March 22, 2023 05:23
Expose BIP32_FLAG_STR_MULTIPATH for the API, but do not implement its
logic yet, except to disallow it for bip32_key_from_parent_path_str
(since this function does not have a multi_index argument to use it).
Also fix the range indicator not being valid after a multi-path, and
detecting a missing initial multi-path child.
This allows invalid paths to be detected while parsing instead of during
script or address generation, and lets callers introspect and iterate
each path in turn.
Store whether each keys path is ranged or a multi-path in its parsed node.

Use this info to only pass the child number/multi-path index when deriving
keys that use these features. This allows mixing ranged/non-ranged plus
multi-path/non-multi-path keys (subject to the other validity
checks, such as ensuring any multi-paths all have the same number of
elements).
Following this change, the canonical way to get all addresses for a
descriptor is:

for (size_t variant = 0; variant < num_variants; ++variant) {
    for (size_t multi_index = 0; multi_index < num_multipaths; ++multi_index) {
        /* Generate for a fixed child number or loop over desired children */
    }
}

Where num_variants and num_multipaths are returned from
wally_descriptor_get_features() - which also returns whether the
descriptor is ranged and thus child_num can take any valid BIP32 value.
Copy link
Contributor

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

some light code review

src/test/test_descriptor.py Outdated Show resolved Hide resolved
src/wasm_package/src/const.js Show resolved Hide resolved
src/test/test_bip32.py Show resolved Hide resolved
src/bip32.c Outdated Show resolved Hide resolved
src/descriptor.c Outdated Show resolved Hide resolved
@jgriffiths jgriffiths merged commit 27b3bd5 into master Apr 3, 2023
@jgriffiths jgriffiths deleted the descriptor_updates branch April 3, 2023 21:02
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.

3 participants