|
@ -40,7 +40,7 @@ var util = require('util'); |
|
|
function Address(version, hash) { |
|
|
function Address(version, hash) { |
|
|
if (hash && hash.length && hash.length != 20) |
|
|
if (hash && hash.length && hash.length != 20) |
|
|
throw new Error('Hash must be 20 bytes'); |
|
|
throw new Error('Hash must be 20 bytes'); |
|
|
Address.super(this, arguments); |
|
|
Address.super_.call(this, version, hash); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
util.inherits(Address, VersionedData); |
|
|
util.inherits(Address, VersionedData); |
|
@ -138,17 +138,12 @@ Address.fromScriptPubKey = function(scriptPubKey, network) { |
|
|
// validates the address
|
|
|
// validates the address
|
|
|
Address.prototype.validate = function() { |
|
|
Address.prototype.validate = function() { |
|
|
this.doAsBinary(function() { |
|
|
this.doAsBinary(function() { |
|
|
Address.super(this, 'validate', arguments); |
|
|
Address.super_.prototype.validate.apply(this); |
|
|
if (this.data.length !== 21) throw new Error('invalid data length'); |
|
|
if (this.data.length !== 21) throw new Error('invalid data length'); |
|
|
}); |
|
|
}); |
|
|
if (typeof this.network() === 'undefined') throw new Error('invalid network'); |
|
|
if (typeof this.network() === 'undefined') throw new Error('invalid network'); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Address.prototype.isValid = function() { |
|
|
|
|
|
var answer = Address.super(this, 'isValid', arguments); |
|
|
|
|
|
return answer; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// returns the network information (livenet or testnet, as described on networks.js) of the address
|
|
|
// returns the network information (livenet or testnet, as described on networks.js) of the address
|
|
|
Address.prototype.network = function() { |
|
|
Address.prototype.network = function() { |
|
|
var version = this.version(); |
|
|
var version = this.version(); |
|
|