bitcore-lib icon indicating copy to clipboard operation
bitcore-lib copied to clipboard

bitcore-lib gets confused when more than one network uses the same xpriv bytes

Open gpip opened this issue 7 years ago • 1 comments

Hello,

When adding a network that shares the same xpriv bytes as another, HDPrivateKey will return the incorrect network because it bases its decision only on those bytes. Should it store the actual network used instead? Maybe the network name?

> var b = require('bitcore-lib');
> var c = require('coininfo');
> var dashmain = c.dash.main.toBitcore();
> dashmain.name = 'dash';
> dashmain.alias = 'dashmainnet';
> b.Networks.add(dashmain);
> b.HDPrivateKey('dash').network
'dash'  # OK
> b.HDPrivateKey(b.Networks.mainnet).network
'dash'  # FAIL

Without modifying:

> var b = require('bitcore-lib');
> b.HDPrivateKey(b.Networks.mainnet).network.name
'livenet'  # OK

gpip avatar Mar 27 '17 13:03 gpip

https://github.com/bitpay/bitcore-lib/pull/145 may fix this issue

priestc avatar Jun 24 '17 18:06 priestc