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

add p2wpkh-p2sh (ypub), p2wpkh (zpub) support #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sh4dowb
Copy link

@sh4dowb sh4dowb commented Sep 16, 2021

I needed to create ypub and zpub extended keys, so I made this small modification.
note: if this doesn't get accepted, for future readers, you can use this instead:
base58.b58encode_check(base58.b58decode_check(xpub_here).replace(0x0488B21E.to_bytes(4, "big"), 0x04b24746.to_bytes(4, "big"))).decode()

Copy link
Owner

@darosior darosior left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request.

I think the hardcoding of specific script types inside the encoding of an extended public key is an unscalable and terrible layer violation that we need to stop disseminate. This is the reason why this library intentionally does not provide support for this (aiming to only implement the BIP32 specification).

That said, given how widespread this practice is i can hear that users of the library may need the conversion no matter what i think the right thing is (eg to work with legacy applications).
To this end i'd be much more comfortable with a pair of standalone functions doing the xpub<->whatever-pub conversion similarly to what is described in the OP, with a note in the doc comment that it should not be used in favour of output descriptors (see also here).

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