|
@ -37,7 +37,7 @@ var JSUtil = require('./util/js'); |
|
|
* |
|
|
* |
|
|
* @param {*} data - The encoded data in various formats |
|
|
* @param {*} data - The encoded data in various formats |
|
|
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' |
|
|
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' |
|
|
* @param {String} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @param {string} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @returns {Address} A new valid and frozen instance of an Address |
|
|
* @returns {Address} A new valid and frozen instance of an Address |
|
|
* @constructor |
|
|
* @constructor |
|
|
*/ |
|
|
*/ |
|
@ -87,7 +87,7 @@ function Address(data, network, type) { |
|
|
* Internal function used to split different kinds of arguments of the constructor |
|
|
* Internal function used to split different kinds of arguments of the constructor |
|
|
* @param {*} data - The encoded data in various formats |
|
|
* @param {*} data - The encoded data in various formats |
|
|
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' |
|
|
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' |
|
|
* @param {String} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @param {string} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @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) { |
|
@ -186,8 +186,8 @@ Address._classifyFromVersion = function(buffer){ |
|
|
* Internal function to transform a bitcoin address buffer |
|
|
* Internal function to transform a bitcoin address buffer |
|
|
* |
|
|
* |
|
|
* @param {Buffer} buffer - An instance of a hex encoded address Buffer |
|
|
* @param {Buffer} buffer - An instance of a hex encoded address Buffer |
|
|
* @param {String} [network] - The network: 'livenet' or 'testnet' |
|
|
* @param {string} [network] - The network: 'livenet' or 'testnet' |
|
|
* @param {String} [type] - The type: 'pubkeyhash' or 'scripthash' |
|
|
* @param {string} [type] - The type: 'pubkeyhash' or 'scripthash' |
|
|
* @returns {Object} An object with keys: hashBuffer, network and type |
|
|
* @returns {Object} An object with keys: hashBuffer, network and type |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
@ -284,9 +284,9 @@ Address.createMultisig = function(publicKeys, threshold, network) { |
|
|
/** |
|
|
/** |
|
|
* Internal function to transform a bitcoin address string |
|
|
* Internal function to transform a bitcoin address string |
|
|
* |
|
|
* |
|
|
* @param {String} data |
|
|
* @param {string} data |
|
|
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String} [type] - The type: 'pubkeyhash' or 'scripthash' |
|
|
* @param {string} [type] - The type: 'pubkeyhash' or 'scripthash' |
|
|
* @returns {Object} An object with keys: hashBuffer, network and type |
|
|
* @returns {Object} An object with keys: hashBuffer, network and type |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
@ -353,7 +353,7 @@ Address.fromScript = function(script, network) { |
|
|
* |
|
|
* |
|
|
* @param {Buffer} buffer - An instance of buffer of the address |
|
|
* @param {Buffer} buffer - An instance of buffer of the address |
|
|
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @param {string} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @returns {Address} A new valid and frozen instance of an Address |
|
|
* @returns {Address} A new valid and frozen instance of an Address |
|
|
*/ |
|
|
*/ |
|
|
Address.fromBuffer = function(buffer, network, type) { |
|
|
Address.fromBuffer = function(buffer, network, type) { |
|
@ -364,9 +364,9 @@ Address.fromBuffer = function(buffer, network, type) { |
|
|
/** |
|
|
/** |
|
|
* Instantiate an address from an address string |
|
|
* Instantiate an address from an address string |
|
|
* |
|
|
* |
|
|
* @param {String} str - An string of the bitcoin address |
|
|
* @param {string} str - An string of the bitcoin address |
|
|
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @param {string} [type] - The type of address: 'script' or 'pubkey' |
|
|
* @returns {Address} A new valid and frozen instance of an Address |
|
|
* @returns {Address} A new valid and frozen instance of an Address |
|
|
*/ |
|
|
*/ |
|
|
Address.fromString = function(str, network, type) { |
|
|
Address.fromString = function(str, network, type) { |
|
@ -377,7 +377,7 @@ Address.fromString = function(str, network, type) { |
|
|
/** |
|
|
/** |
|
|
* Instantiate an address from JSON |
|
|
* Instantiate an address from JSON |
|
|
* |
|
|
* |
|
|
* @param {String} json - An JSON string or Object with keys: hash, network and type |
|
|
* @param {string} json - An JSON string or Object with keys: hash, network and type |
|
|
* @returns {Address} A new valid instance of an Address |
|
|
* @returns {Address} A new valid instance of an Address |
|
|
*/ |
|
|
*/ |
|
|
Address.fromJSON = function fromJSON(json) { |
|
|
Address.fromJSON = function fromJSON(json) { |
|
@ -401,9 +401,9 @@ Address.fromJSON = function fromJSON(json) { |
|
|
* var error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet'); |
|
|
* var error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet'); |
|
|
* ``` |
|
|
* ``` |
|
|
* |
|
|
* |
|
|
* @param {String} data - The encoded data |
|
|
* @param {string} data - The encoded data |
|
|
* @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String} type - The type of address: 'script' or 'pubkey' |
|
|
* @param {string} type - The type of address: 'script' or 'pubkey' |
|
|
* @returns {null|Error} The corresponding error message |
|
|
* @returns {null|Error} The corresponding error message |
|
|
*/ |
|
|
*/ |
|
|
Address.getValidationError = function(data, network, type) { |
|
|
Address.getValidationError = function(data, network, type) { |
|
@ -425,9 +425,9 @@ Address.getValidationError = function(data, network, type) { |
|
|
* assert(Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet')); |
|
|
* assert(Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet')); |
|
|
* ``` |
|
|
* ``` |
|
|
* |
|
|
* |
|
|
* @param {String} data - The encoded data |
|
|
* @param {string} data - The encoded data |
|
|
* @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' |
|
|
* @param {String} type - The type of address: 'script' or 'pubkey' |
|
|
* @param {string} type - The type of address: 'script' or 'pubkey' |
|
|
* @returns {boolean} The corresponding error message |
|
|
* @returns {boolean} The corresponding error message |
|
|
*/ |
|
|
*/ |
|
|
Address.isValid = function(data, network, type) { |
|
|
Address.isValid = function(data, network, type) { |
|
@ -473,7 +473,7 @@ Address.prototype.toObject = function toObject() { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @returns {String} A JSON representation of a plain object with the address information |
|
|
* @returns {string} A JSON representation of a plain object with the address information |
|
|
*/ |
|
|
*/ |
|
|
Address.prototype.toJSON = function toJSON() { |
|
|
Address.prototype.toJSON = function toJSON() { |
|
|
return JSON.stringify(this.toObject()); |
|
|
return JSON.stringify(this.toObject()); |
|
@ -482,7 +482,7 @@ Address.prototype.toJSON = function toJSON() { |
|
|
/** |
|
|
/** |
|
|
* Will return a the string representation of the address |
|
|
* Will return a the string representation of the address |
|
|
* |
|
|
* |
|
|
* @returns {String} Bitcoin address |
|
|
* @returns {string} Bitcoin address |
|
|
*/ |
|
|
*/ |
|
|
Address.prototype.toString = function() { |
|
|
Address.prototype.toString = function() { |
|
|
return Base58Check.encode(this.toBuffer()); |
|
|
return Base58Check.encode(this.toBuffer()); |
|
@ -491,7 +491,7 @@ Address.prototype.toString = function() { |
|
|
/** |
|
|
/** |
|
|
* Will return a string formatted for the console |
|
|
* Will return a string formatted for the console |
|
|
* |
|
|
* |
|
|
* @returns {String} Bitcoin address |
|
|
* @returns {string} Bitcoin address |
|
|
*/ |
|
|
*/ |
|
|
Address.prototype.inspect = function() { |
|
|
Address.prototype.inspect = function() { |
|
|
return '<Address: ' + this.toString() + ', type: '+this.type+', network: '+this.network+'>'; |
|
|
return '<Address: ' + this.toString() + ', type: '+this.type+', network: '+this.network+'>'; |
|
|