Bitcoin-com / bitbox-sdk

BITBOX SDK for Bitcoin Cash
https://developer.bitcoin.com/bitbox
MIT License
90 stars 62 forks source link

Wallet Derivation #47

Open christroutner opened 5 years ago

christroutner commented 5 years ago

Different wallets use different HD derivation paths. There has been some confusion as to what derivation BITBOX uses and what other wallets use. This is the place to discuss what derivation paths to use and where to use them.

BITBOX examples use the "m/44'/145'/0'" derivation, but any derivation path can be used with the the masterHDNode.derivePath call. You can generate an output like the below by running this create-wallet example.

BIP44 Account: "m/44'/145'/0'"
m/44'/145'/0'/0/0: bitcoincash:qqvhu2v2lse0xq58jenwap9c2cxnxq7grv5xts4uc5
m/44'/145'/0'/0/1: bitcoincash:qp0w3ur8679t6uygkssn8jmvsm63jdzka5rypmj0tr
m/44'/145'/0'/0/2: bitcoincash:qzgnjhq9hh97at0z7u0g7qq0evsutauy5y9xpvrug5
m/44'/145'/0'/0/3: bitcoincash:qpq6zhhr5jaj6kemt8mkh4uadeyscp6l8q8zhlhheh
m/44'/145'/0'/0/4: bitcoincash:qr8vqugsytcczfxglhthwfv7znkvwzxv3ufs7sfmhj
m/44'/145'/0'/0/5: bitcoincash:qrx65g8rm2lanvjtm69fgk0um926q6n6jus9xlkrvt
m/44'/145'/0'/0/6: bitcoincash:qptupdrmrdp9y9k6mqdydyxkx0ffejsdp5x7kcjsej
m/44'/145'/0'/0/7: bitcoincash:qr2teks3lkgu96f6jgw0gnf86987lfpswy9ue2fd02
m/44'/145'/0'/0/8: bitcoincash:qq7zjhptdk4847l36aypdaa57sks5wd26yflw66tsc
m/44'/145'/0'/0/9: bitcoincash:qrzf7y6agjzzrs2c6drdf755v7j57ygagg2axzuyw2
christroutner commented 5 years ago

I saw this note in the honest.cash telegram channel:

Yours and bitcoin.com both use m/44'/0'/0' So those should be interchangeable.

Can anyone verify the accuracy of this?

christroutner commented 5 years ago

Adding a link to this Reddit discussion: https://www.reddit.com/r/btc/comments/a3089d/new_on_honest_cash_custom_hd_derivation_paths_by/

m4ktub commented 5 years ago

The Bitcoin.com wallet (and previously the Yours web wallet) continued to use the same derivation path used for BTC, that is, m/44'/0'/0' which will results in addresses identified by the following paths:

m/44'/0'/0'/0/0
m/44'/0'/0'/0/1
m/44'/0'/0'/0/2
m/44'/0'/0'/0/<n>

It can be easily verified by:

  1. Creating a new wallet with Bitcoin.com,
  2. Going to https://iancoleman.io/bip39/ and pasting the seed,
  3. Press receive in the wallet,
  4. Convert the first address of the BIP39 website to CashAddr and compare.

I also want to point out a similar issue in Bitpay's wallet repository (bitpay/copay #7216).

emergent-reasons commented 5 years ago

Let me share what I submitted to electron cash on this issue. The way honest.cash lists their derivation path which they intend to resolve to a single address (m/44'/0'/0'/0/0) suggests an interesting use case where a fully specified derivation path (down to a single address) could be interpreted as just a single private key.

Electron does not do that currently but I suggested it in that issue. Currently EC somehow produces a whole HD wallet from that path.

Not sure how bitbox handles it. Probably correctly if honest.cash wallet is working now!

emergent-reasons commented 5 years ago

FWIW I have listed up the derivation paths that I collected over time by asking wallet makers.

for software wallets for hardware wallets

christroutner commented 5 years ago

Thank you all for your contributions.

Honest.cash also has this article on the deriviation path they use and the logic behind it: https://honest.cash/honest_cash/new-on-honest-cash-custom-hd-derivation-paths-123/

christroutner commented 5 years ago

Additional information on wallet deriviation compatibility: https://honest.cash/honest_cash/how-to-import-your-honest-wallet-into-bitcoincom-wallet-1690 https://honest.cash/honest_cash/how-to-import-your-honest-wallet-into-electron-cash-134