ECPair: no elseif needed, move default for clarity

This commit is contained in:
Daniel Cousens 2016-04-27 18:04:35 +10:00
parent 00cee340dd
commit ea4ce4e2a6

View file

@ -58,7 +58,6 @@ ECPair.fromPublicKeyBuffer = function (buffer, network) {
}
ECPair.fromWIF = function (string, network) {
network = network || NETWORKS.bitcoin
var decoded = wif.decode(string)
var version = decoded.version
@ -71,8 +70,9 @@ ECPair.fromWIF = function (string, network) {
if (!network) throw new Error('Unknown network version')
// network
} else if (network) {
// check version only if defined
} else {
network = network || NETWORKS.bitcoin
if (version !== network.wif) throw new Error('Invalid network version')
}