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

Properly specify and support the different types of Bitcoin xPubs (add full P2SH-P2WPKH and WPKH support. #1562

Closed
LefterisJP opened this issue Oct 6, 2020 · 2 comments · Fixed by #1622
Assignees
Milestone

Comments

@LefterisJP
Copy link
Member

LefterisJP commented Oct 6, 2020

Abstract

With v1.8.1 we added the first bitcoin xPub support in Rotki. A user can provide an xpub starting with the xpub prefix and rotki will assume it's a legacy xpub. m/44'/0'/x' => P2PKH. If the prefix starts with zpub it will assume it's a native segwit m/84/0'/x' => WPKH` type of xpub.

But this is missing some functionality. The zpub prefix is electrum specific and not bitcoin standard. The xpub may still start with xpub and still be of WPKH type.

Finally we are missing support for segwit xpubs, m/49'/0'/x' => P2SH-P2WPKH. In electrum they are prefixed with ypub.

Task

At xpub input allow the user to specify the type of xpub.

  • P2PKH (legacy) with account path `m/44'/0'/x'
  • P2SH-P2WPKH (segwit) with account path m/49'/0'/x'
  • WPKH (native segwit) with account path m/84/0'/x'

Also allow auto completion of the type if the xpub is electrum style. If the user given xpub starts with:

  • xpub -> P2PKH
  • ypub -> P2SH-P2WPKH
  • zpub -> WPKH

In the frontend there will be a choice of xpub type, but in the end what is sent to the backend (so we avoid extra fields) is the xpub with the proper prefix. xpub, ypub, zpub. The backend will read the prefix and treat the xpub accordingly. When returning information on an xpub we coudl add an extra field for the type. We could also just use the xpub prefix for this. @kelsos What do you think? (can also respond in discord)

@kilrau
Copy link

kilrau commented Oct 23, 2020

Also allow auto completion of the type if the xpub is electrum style. If the user given xpub starts with:

* `xpub` -> `P2PKH`

* `ypub` -> `P2SH-P2WPKH`

* `zpub` -> `WPKH`

Just as a side note: I don't think that will work in all cases, but think is good enough for now. I have a native segwit xpub here (account path m/84'/0'/0') and my wallet offers me two representations of such: one starting with xpub, one starting with zpub.

@LefterisJP
Copy link
Member Author

We will also allow choice of xpub type. It's just that we will use the prefix as hint. And we will save the type by using the prefix. So it should work no matter which representation you choose as long as you specify the type properly when entering it via the UI.

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 a pull request may close this issue.

2 participants