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

How can I support P2SH-P2WPKH(BIP49) transaction in bcoin wallet? #606

Closed
kelvinkuo opened this issue Sep 11, 2018 · 8 comments
Closed

How can I support P2SH-P2WPKH(BIP49) transaction in bcoin wallet? #606

kelvinkuo opened this issue Sep 11, 2018 · 8 comments

Comments

@kelvinkuo
Copy link

I want create P2SH-P2WPKH wallet, But bcoin only support P2PKH/P2SH/P2WPKH.
Anyone has a solution?

@bucko13
Copy link
Contributor

bucko13 commented Sep 11, 2018

bcoin also supports P2SH-P2WPKH, they're called nested addresses in the API. is there something in particular you're having problems with?

@kelvinkuo
Copy link
Author

kelvinkuo commented Sep 12, 2018

@bucko13 I create a witness and pubkeyhash wallet with mnemonic. But the nested-address is different from the online creator https://iancoleman.io/bip39/ . And if I import a pubkey, bcoin doesn't support prefix 'ypub' Account key.

@pinheadmz
Copy link
Member

pinheadmz commented Sep 12, 2018

Hi @kelvinkuo bcoin actually handles "nested" addresses with a branch value of 2, similar to how recieve and change are 0 and 1 respectively. So the bip39 (actually bip44) path bcoin uses is different from the website you reference.

See
https://github.com/bcoin-org/bcoin/blob/master/lib/wallet/account.js#L358

And as you have already discovered, ypub is not yet supported in bcoin.

@kelvinkuo
Copy link
Author

kelvinkuo commented Sep 13, 2018

@pinheadmz thanks,But many wallets use BIP49(`purpose 49) way to support P2SH-P2WPKH. I want know `change = 2, which BIP defined this path???

@pinheadmz
Copy link
Member

BIP49 is a proposal still in draft status. The document even mentions one strategy to nested witness P2SH addresses is to maintain a bip44 structure with a new "branch". This is the strategy implemented by bcoin for (what I presume) is two main reasons:

  1. Bcoin has used bip44 since inception and switching to bip49 means a lot of new refactoring work as well as breaking changes to our existing userbase.

  2. We hope that nested witness addresses are quickly replaced by native bech32 addresses, meaning the work required to rebuild our wallet would be quickly obsolete.

bcoin users can easily create nested addresses (or native bech32 addresses, or legacy addresses) with the library if desired. We can not always garuntee interoperability with every other wallet out there. If you want to fork the bcoin wallet module to derive nested addresses for all purposes on a bip49 path, I think that would be a great contribution! But it is unlikely to get merged to master.

@braydonf
Copy link
Contributor

braydonf commented Sep 17, 2018

The total bytes for a nested witness into p2sh is overall larger than p2sh or p2pkh equivalent, and for that reason I think it's generally not recommended.

@kelvinkuo
Copy link
Author

@pinheadmz got it. I think I need hack some code to support BIP49.
Thanks for your reply.

@bucko13
Copy link
Contributor

bucko13 commented Oct 30, 2018

@kelvinkuo you should be able to try this out with @pinheadmz PR. Not sure what the chances of this getting merged to master but it has been tested and should work for watch-only trezor wallets! Will close this issue.

@bucko13 bucko13 closed this as completed Oct 30, 2018
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

No branches or pull requests

4 participants