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

Throw when invalid network string is passed in

Open gabegattis opened this issue 8 years ago • 1 comments

In some cases, we pass in a network as a string to specify the network of some other argument. An example is creating an address

var bitcore = require('bitcore-lib');
var myAddress = bitcore.Address.fromString('135zDqhbNcmPk3gbyeJmH75yiLdVZechsK', 'livenet');

but I can pass in an invalid network string and it will silently default to livenet instead of throwing

var myOtherAddress = bitcore.Address.fromString('135zDqhbNcmPk3gbyeJmH75yiLdVZechsK', 'derpnet');
console.log(myOtherAddress); // <Address: 135zDqhbNcmPk3gbyeJmH75yiLdVZechsK, type: pubkeyhash, network: livenet>

We should probably throw an error if an invalid network string gets passed in to functions like this

gabegattis avatar Dec 15 '15 21:12 gabegattis

mark 到此一游。

philsong avatar Mar 01 '16 09:03 philsong