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

chaincfg: Add RegisterHDKeyID func to populate HD key ID pairs #1617

Merged
merged 1 commit into from
Sep 8, 2020

Conversation

onyb
Copy link
Collaborator

@onyb onyb commented Aug 22, 2020

Issue https://github.com/btcsuite/btcutil/issues/179

This is a first step towards allowing library packages (such as btcutil, but not limited to it) to register SLIP-0132 (or custom) HD version bytes. The version bytes itself are not included in this PR; it simply provides a public function to populate them.

Currently, the only way to register HD version bytes is by initializing chaincfg.Params struct, and registering it during package init. RegisterHDKeyID provides a way to populate custom HD version bytes, without having to create new chaincfg.Params instances. This is useful for library packages who want to use non-standard version bytes for serializing extended keys, such as the ones documented in SLIP-0132.

This function is complementary to HDPrivateKeyToPublicKeyID, which is used to lookup previously registered key IDs.

Copy link
Collaborator

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

LGTM

chaincfg/params_test.go Show resolved Hide resolved
Currently, the only way to register HD version bytes is by initializing
chaincfg.Params struct, and registering it during package init.
RegisterHDKeyID provides a way to populate custom HD version bytes,
without having to create new chaincfg.Params instances. This is useful
for library packages who want to use non-standard version bytes for
serializing extended keys, such as the ones documented in SLIP-0132.

This function is complementary to HDPrivateKeyToPublicKeyID, which is
used to lookup previously registered key IDs.
Copy link

@mflaxman mflaxman left a comment

Choose a reason for hiding this comment

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

Very useful, thank you!

@onyb onyb added this to the 0.22.0 milestone Sep 7, 2020
Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

Looks good.
OK

@jcvernaleo jcvernaleo merged commit bdab8df into btcsuite:master Sep 8, 2020
@onyb onyb deleted the slip0132 branch September 8, 2020 13:59
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