Explorations for support of N keychains #226
Draft
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.
Just pushing here to show/discuss as I explore the potential for support of any number of descriptors for the Wallet type for maybe a 3.0.
Overview
The gist of my idea is a
KeyRing
(KeychainRing? KeychainSet?), which is basically a structure that holds a vector of keychains. You create a key ring with any number of descriptors (must have 1 default, can have 1 change, plus any number of others). The wallet constructors take this KeyRing as an argument, and from there the wallet methods need to be adjusted to work with the new paradigm.The
KeyRing
has methods to add/check/query descriptors it holds, and is where the domain logic of ensuring only 1 descriptor is the default, that all descriptors use the same network, and any other requirements we have for basically this group of keychains lives. The wallet type then gets a new field key_ring, which it can use to query things likeKeyRing::get_default_descriptor()
orKeyRing::list_keychains()
.Resulting API
The API is showcased in the
wallet/examples/n_keychains.rs
file.