|
|
@ -26,7 +26,7 @@ Network.prototype.toString = function toString() { |
|
|
|
* @param {string|Array} keys - if set, only check if the magic number associated with this name matches |
|
|
|
* @return Network |
|
|
|
*/ |
|
|
|
function getNetwork(arg, keys) { |
|
|
|
function get(arg, keys) { |
|
|
|
if (~networks.indexOf(arg)) { |
|
|
|
return arg; |
|
|
|
} |
|
|
@ -34,8 +34,11 @@ function getNetwork(arg, keys) { |
|
|
|
if (!_.isArray(keys)) { |
|
|
|
keys = [keys]; |
|
|
|
} |
|
|
|
var containsArg = function(key) { |
|
|
|
return networks[index][key] === arg; |
|
|
|
}; |
|
|
|
for (var index in networks) { |
|
|
|
if (_.any(keys, function(key) { return networks[index][key] === arg; })) { |
|
|
|
if (_.any(keys, containsArg)) { |
|
|
|
return networks[index]; |
|
|
|
} |
|
|
|
} |
|
|
@ -115,7 +118,7 @@ addNetwork({ |
|
|
|
pubkeyhash: 0x00, |
|
|
|
privatekey: 0x80, |
|
|
|
scripthash: 0x05, |
|
|
|
xpubkey: 0x0488b21e, |
|
|
|
xpubkey: 0x0488b21e, |
|
|
|
xprivkey: 0x0488ade4, |
|
|
|
networkMagic: 0xf9beb4d9, |
|
|
|
port: 8333, |
|
|
@ -148,16 +151,16 @@ addNetwork({ |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* @instance |
|
|
|
* @member Networks#livenet |
|
|
|
*/ |
|
|
|
var livenet = getNetwork('livenet'); |
|
|
|
* @instance |
|
|
|
* @member Networks#livenet |
|
|
|
*/ |
|
|
|
var livenet = get('livenet'); |
|
|
|
|
|
|
|
/** |
|
|
|
* @instance |
|
|
|
* @member Networks#testnet |
|
|
|
*/ |
|
|
|
var testnet = getNetwork('testnet'); |
|
|
|
* @instance |
|
|
|
* @member Networks#testnet |
|
|
|
*/ |
|
|
|
var testnet = get('testnet'); |
|
|
|
|
|
|
|
/** |
|
|
|
* @namespace Networks |
|
|
@ -169,5 +172,5 @@ module.exports = { |
|
|
|
livenet: livenet, |
|
|
|
mainnet: livenet, |
|
|
|
testnet: testnet, |
|
|
|
get: getNetwork |
|
|
|
get: get |
|
|
|
}; |
|
|
|