|
@ -100,15 +100,17 @@ function Address(data, network, type) { |
|
|
* @returns {Object} An "info" object with "type", "network", and "hashBuffer" |
|
|
* @returns {Object} An "info" object with "type", "network", and "hashBuffer" |
|
|
*/ |
|
|
*/ |
|
|
Address.prototype._classifyArguments = function(data, network, type) { |
|
|
Address.prototype._classifyArguments = function(data, network, type) { |
|
|
|
|
|
var PublicKey = require('./publickey'); |
|
|
|
|
|
var Script = require('./script'); |
|
|
/* jshint maxcomplexity: 10 */ |
|
|
/* jshint maxcomplexity: 10 */ |
|
|
// transform and validate input data
|
|
|
// transform and validate input data
|
|
|
if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 20) { |
|
|
if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 20) { |
|
|
return Address._transformHash(data); |
|
|
return Address._transformHash(data); |
|
|
} else if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 21) { |
|
|
} else if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 21) { |
|
|
return Address._transformBuffer(data, network, type); |
|
|
return Address._transformBuffer(data, network, type); |
|
|
} else if (data.constructor && (data.constructor.name && data.constructor.name === 'PublicKey')) { |
|
|
} else if (data instanceof PublicKey) { |
|
|
return Address._transformPublicKey(data); |
|
|
return Address._transformPublicKey(data); |
|
|
} else if (data.constructor && (data.constructor.name && data.constructor.name === 'Script')) { |
|
|
} else if (data instanceof Script) { |
|
|
return Address._transformScript(data, network); |
|
|
return Address._transformScript(data, network); |
|
|
} else if (typeof(data) === 'string') { |
|
|
} else if (typeof(data) === 'string') { |
|
|
return Address._transformString(data, network, type); |
|
|
return Address._transformString(data, network, type); |
|
|