Skip to content
New issue

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

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

Already on GitHub? # to your account

Re-name as_public -> to_public #377

Merged
merged 6 commits into from
May 9, 2022

Conversation

tcharding
Copy link
Member

As we have been doing in rust-bitcoin attempt to use idiomatic names for our conversion functions.

Re-name the key conversion functions as_public to be to_public because they take a borrowed type and return an owned, non-Copy type.

While we are it at do a bunch of refactoring to the individual functions. Each done as a separate patch, can drop any not wanted.

tcharding added 6 commits May 3, 2022 10:29
There is no need to mutate the `self` variable, doing so makes the code
subjectively harder to read.

Refactor the `derive` method to not use mutable variables.
The first key in a bip32 extended key is commonly referred to as the
'master' key not the 'root' key.
According to Rust naming convention this method should use the `to_`
prefix because it converts from a borrowed->owned (non-`Copy`) type.

Re-name the conversion methods for converting from various
private/secret keys to the associated public keys to `to_public`.
The `to_public` method on `DescriptorSinglePriv` never errors, no need
to return an error type.
In an effort to make the code cleaner do some refactorings to the
`to_public` method on `DescriptorXKey<bip32::ExtendedPrivKey>`.

Re-factor only, no logic changes.
Do minor refactor to the `to_public` method on `DesciptorSecretKey`.

Re-factor only, no logic changes.
@tcharding tcharding force-pushed the descriptor-key-to-public branch from 98a7605 to be5e042 Compare May 3, 2022 00:38
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK be5e042

Note that this is an API-breaking change.

@sanket1729 sanket1729 merged commit 9f1290e into rust-bitcoin:master May 9, 2022
@tcharding tcharding deleted the descriptor-key-to-public branch May 10, 2022 01:45
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants