gcash/bchwallet

Bitcoin Cash cointype

cpacia opened this issue · 4 comments

The chaincfg.Params object in bchd contains a HDCoinType field which specifies the bip44 cointype. For Bitcoin (btc) the cointype is 0, but according to the bip44, Bitcoin Cash is given the cointype of 145 (and testnet is 1).

The problem we have is the bchwallet has hardcoded the cointype to 0 and doesn't bother to load the cointype from the params. If we change the hardcoded cointype to 145 it breaks a lot of tests (which are rather poorly written as it causes panics that are difficult to trace through), and further the cointype would not be loaded from the params so, for example, testnet will not use 1.

The question for us is do we want to use a cointype of 145 to be consistent with the bip44 spec? Is anyone else doing that? If so, do we want to put in the work to make it load the cointype from the params (which is quite a bit of work).

A decision should be made before the wallet is released because changing it afterwards can break compatibility with existing users.

I think we remove it from the params, and have it look up the cointype in code for testnet/mainnet. I am not sure why it was a parameter if the values are known for the network. Seems odd to be able to specify it when other flags imply it anyways.

I think the idea of putting it in the params is if you create a new network (like how bitcoin cash forked off), then you could just create new network params and the wallet would continue to work without changes.

Also do you know of anyone else using bip44 in Bitcoin Cash and are they using 145 (we use 145 in OpenBazaar but not sure about anyone else)?

Just to comment on the last question you had. A quick search of my records show 145' users:

  • badgerwallet.cash
  • mttr.app
  • of course trezor accounts made through their web interface
  • I think also ledger accounts made through their app