dan-da/hd-wallet-addrs

Segwit (ypub) support?

robclark56 opened this issue · 4 comments

Dan,

Love the code. But any chance of adding BIP49 segwit support? I.e. supply a ypub, and get segwit addresses ('3xxxxx')

yeah that would be good. well, to do it right I guess it should support both p2sh and bech32 formats.

I don't have much time for it right now, but I would accept patches along those lines. and will keep it mind to add anyway when I have a free moment.

thanks in advance. waiting for that very much.

Supporting ypub, zpub is pretty straightforward since they are just like existing xpub, with difference being the address types that get created.

However, the larger topic of "supporting segwit addresses" is complicated by the fact that bitcoin-core does not even use ypub for segwit, but rather xpub derivation for legacy, p2sh-segwit, and bech32. afaict, supporting this requires deriving the xpub keys, and then for each key finding all 3 address types and looking up all 3 on the blockchain, which of course is slower.

So it's really two totally distinct features to support "segwit" and somewhat unclear to me which direction the industry will go long term.

As of version v0.1.8 segwit extended keys (ypub, zpub) can be read and generate appropriate addresses (p2sh-segwit or bech32).

bitcoin-core style segwit addr derivation from xpub is not supported. A separate issue can be opened for that if someone has a need for it.

closing.