|
|
@ -157,14 +157,18 @@ PrivateKey._transformBuffer = function(buf, network) { |
|
|
|
} |
|
|
|
|
|
|
|
info.network = Networks.get(buf[0], 'privatekey'); |
|
|
|
if (buf[0] === Networks.livenet.privatekey) { |
|
|
|
info.network = Networks.livenet; |
|
|
|
} else if (buf[0] === Networks.testnet.privatekey) { |
|
|
|
info.network = Networks.testnet; |
|
|
|
} else { |
|
|
|
|
|
|
|
var allNetworks = Networks.all(); |
|
|
|
var matches = _.filter( allNetworks, function( network) { |
|
|
|
return buf[0] === network.privatekey; |
|
|
|
}); |
|
|
|
|
|
|
|
if (matches.length !== 1) { |
|
|
|
throw new Error('Invalid network'); |
|
|
|
} |
|
|
|
|
|
|
|
info.network = matches[0]; |
|
|
|
|
|
|
|
if (network && info.network !== Networks.get(network)) { |
|
|
|
throw new TypeError('Private key network mismatch'); |
|
|
|
} |
|
|
|