|
|
@ -32,15 +32,15 @@ Address.prototype.fromString = function(str) { |
|
|
|
if (version === constants['mainnet']['pubkeyhash']) { |
|
|
|
this.networkstr = 'mainnet'; |
|
|
|
this.typestr = 'pubkeyhash'; |
|
|
|
} else if (version === constants['mainnet']['p2sh']) { |
|
|
|
} else if (version === constants['mainnet']['scripthash']) { |
|
|
|
this.networkstr = 'mainnet'; |
|
|
|
this.typestr = 'p2sh'; |
|
|
|
this.typestr = 'scripthash'; |
|
|
|
} else if (version === constants['testnet']['pubkeyhash']) { |
|
|
|
this.networkstr = 'testnet'; |
|
|
|
this.typestr = 'pubkeyhash'; |
|
|
|
} else if (version === constants['testnet']['p2sh']) { |
|
|
|
} else if (version === constants['testnet']['scripthash']) { |
|
|
|
this.networkstr = 'testnet'; |
|
|
|
this.typestr = 'p2sh'; |
|
|
|
this.typestr = 'scripthash'; |
|
|
|
} else { |
|
|
|
this.networkstr = 'unknown'; |
|
|
|
this.typestr = 'unknown'; |
|
|
@ -84,8 +84,8 @@ Address.prototype.validate = function() { |
|
|
|
throw new Error('hash must be a buffer of 20 bytes'); |
|
|
|
if (this.networkstr !== 'mainnet' && this.networkstr !== 'testnet') |
|
|
|
throw new Error('networkstr must be "mainnet" or "testnet"'); |
|
|
|
if (this.typestr !== 'pubkeyhash' && this.typestr !== 'p2sh') |
|
|
|
throw new Error('typestr must be "pubkeyhash" or "p2sh"'); |
|
|
|
if (this.typestr !== 'pubkeyhash' && this.typestr !== 'scripthash') |
|
|
|
throw new Error('typestr must be "pubkeyhash" or "scripthash"'); |
|
|
|
return this; |
|
|
|
}; |
|
|
|
|
|
|
|