bitcore-lib
bitcore-lib copied to clipboard
Throw when invalid network string is passed in
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
mark 到此一游。