8000 Rename xpub and xpriv types by tcharding · Pull Request #2019 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Rename xpub and xpriv types #2019

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

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

tcharding
Copy link
Member

The BIP-32 extended public key and extended private key exist in the Bitcoin vernacular as xpub and xpriv. We can use these terms with no loss of clarity.

Rename our current BIP-32 types

  • ExtendedPubKey to Xpub
  • ExtendedPrivKey to Xpriv

This patch is a mechanical search-and-replace, followed by running the formatter, no other manual changes.

The BIP-32 extended public key and extended private key exist in the
Bitcoin vernacular as xpub and xpriv. We can use these terms with no
loss of clarity.

Rename our current BIP-32 types

- `ExtendedPubKey` to `Xpub`
- `ExtendedPrivKey` to `Xpriv`

This patch is a mechanical search-and-replace, followed by running the
formatter, no other manual changes.
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 be05f9d

@tcharding
Copy link
Member Author
tcharding commented Aug 22, 2023

Just realized this clashes with miniscripts's DescriptorSecretKey

pub enum DescriptorSecretKey {
    /// Single private key.
    Single(SinglePriv),
    /// Extended private key (xpriv).
    XPrv(DescriptorXKey<bip32::ExtendedPrivKey>),
    /// Multiple extended private keys.
    MultiXPrv(DescriptorMultiXKey<bip32::ExtendedPrivKey>),
}

Shall we settle on one Xpub/Xpriv vs XPub/XPriv and use it in both repos? My vote goes for Xpub/Xpriv because xpub for reasons stated in PR desription.

@apoelstra
Copy link
Member

Where is the clash?

@tcharding
Copy link
Member Author
tcharding commented Aug 23, 2023

The capital P in XPriv (and XPub in other parts of miniscript code) - this PR uses Xpriv and Xpub.

@apoelstra
Copy link
Member

Oh. Yes, we should use a capital P. I'm glad that you noticed the difference!

@apoelstra
Copy link
Member

Well, now I'm unsure. Regardless, we should be consistent.

@tcharding
Copy link
Member Author
tcharding commented Aug 24, 2023

ouch I was totally sure ... then I read "Well, now I'm unsure" and now I'm unsure :)

"xpub" is a word implies Xpub but we have so many other unrelated x things XOnlyPublicKey, DescritorXKey and then because of use of Pub inside other identifiers here it looks weird to have Xpub

pub enum DescriptorPublicKey {
    /// Single public key.
    Single(SinglePub),
    /// Extended public key (xpub).
    XPub(DescriptorXKey<bip32::ExtendedPubKey>),
    /// Multiple extended public keys.
    MultiXPub(DescriptorMultiXKey<bip32::ExtendedPubKey>),
}

After writing all that I vote Xpub!

cc @sanket1729 if you have nothing more useful to do that debate the finer points of naming :)

@sanket1729
Copy link
Member

If we really want to name things unambiguously, Xpub can be bip32::XPub, and key::XOnlyPublicKey in miniscript codebase for ease of disambiguation.

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 be05f9d

@tcharding
Copy link
Member Author

That is slightly off topic but yes, I've been warming to these extra level of path lately since playing around in miniscript, I've also been trying to ensure types have good descriptive paths. See my latest epic refactor #1981

@apoelstra
Copy link
Member

Ok, Xpub sounds fine to me. Let's do it. We should maybe change rust-miniscript to match.

FWIW the idea behind XPub is that X is a word (it's short for "extended", except in "x-only public key" where it's short for "x").

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 be05f9d

@apoelstra
Copy link
Member

Will hold of on merging to let @tcharding get one more word in about XPub vs Xpub.

@tcharding
Copy link
Member Author

Xpub lets go! I'll keep it in mind during my current work in miniscript.

@apoelstra apoelstra merged commit 082bd03 into rust-bitcoin:master Aug 25, 2023
@stevenroose
Copy link
Collaborator

Damn two weeks merge window? I'd have NACKed this. xpub literally stands for ExtendedPubkey and ExtendedPubkey isn't that long.. Are we gonna shorten PublicKey to Pk too? Tx?

I'm probably on one of the most archaic and unaided dev environments (vim..) and I don't mind typing Extended a few times.

@tcharding
Copy link
Member Author

The ExtendedPubkey names were also annoying because they use "pubkey" and we have PublicKey not Pubkey. This was a way to solve that without bikeshedding that difference.

Damn two weeks merge window?

We can't wait for ever bro, two weeks is long enough to take a holiday and still get your nacks in.

@apoelstra
Copy link
Member

I'm probably on one of the most archaic and unaided dev environments (vim..) and I don't mind typing Extended a few times.

I'm also using bare vim and don't mind typing Extended, but X is used as an abbreviation for "extended" all over the bitcoin ecosystem. The term "xpub" and "xpriv" are used far more often than "extended pubkey" and "extended privkey", and I expect that most people using those terms aren't even aware that they're abbreviations.

@tcharding tcharding deleted the 08-32-bip32-xpub-xpriv branch May 22, 2024 23:13
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.

4 participants
0