Skip to content

Conversation

@tcharding
Copy link
Member

In an effort to better understand the descriptor module and its associated types; do some refactoring and re-naming of types making the key struct identifiers more terse.

  • Patch 1: refactor, code layout
  • Patch 2: docs improvements
  • Patch 3: Minor refactor
  • Patch 4: Use more terse names, this is the bulk of the PR

If this is too invasive for someone only recently making their way around the crate, feel free to say so :)

Source files are easier to read if the most important stuff comes first.

We have a bunch of key structs, order them pub/priv and in order of
importance i.e., declare things below where they are first used.

Refactor only, no logic changes.
Improve the documentation on the various key structs.
The `KeySource` type is a type alias from `bitcoin::bip32` for a
tuple (fingerprint, derivation_path). In other places in the code we use
the full tuple, we should be uniform and use one or the other. Elect to
use the tuple.

Use full tuple `(FingerPrint, DerivationPath)` instead of `KeySource`.
We have a plethora of key structs in the `key` module. Attempt to use
more terse names without loosing any clarity.

In particular:

1. Variants

- Replace SinglePub with Single
- Replace SinglePriv with Single

The variants `SinglePub`, and `SinglePriv` stutter, we know what keys
they are so can use `Single` with no loss of clarity.

2. Remove `Descriptor` from the nested descriptor types, users can use
`descriptor::singlePub` if needed.
Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK 5a8514a. These changes are increase the code quality.

@sanket1729 sanket1729 merged commit 709d641 into rust-bitcoin:master Apr 30, 2022
@tcharding tcharding deleted the more-terse branch May 1, 2022 23:49
heap-coder added a commit to heap-coder/rust-miniscript that referenced this pull request Sep 27, 2025
…tor module

5a8514ab351bbd23b998a39a7b36d88976462512 Use more terse names for descriptor keys (Tobin C. Harding)
51e07db3d1c61001c7449c2577f2ad46a803f175 Use full tuple instead of KeySource (Tobin C. Harding)
33af3ad24ee657f62198c28f65a9c363e3c26fa4 Improve docs on key structs (Tobin C. Harding)
3bed0db6b79997f4c00d1065eb23c7dba83b4776 Re-order key structs (Tobin C. Harding)

Pull request description:

  In an effort to better understand the `descriptor` module and its associated types; do some refactoring and re-naming of types making the key struct identifiers more terse.

  - Patch 1: refactor, code layout
  - Patch 2: docs improvements
  - Patch 3: Minor refactor
  - Patch 4: Use more terse names, this is the bulk of the PR

  If this is too invasive for someone only recently making their way around the crate, feel free to say so :)

ACKs for top commit:
  sanket1729:
    ACK 5a8514ab351bbd23b998a39a7b36d88976462512. These changes are increase the code quality.

Tree-SHA512: 5a140d3cc9273304873c0e94861f5f28506f47a9cfec17d9980676c09931b8fab96253bf26cbe3c5b4071823dfda0f65d498622111e0a8cd8a95301fda79a2c9
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