|
|
@ -437,6 +437,29 @@ Address.isValid = function(data, network, type) { |
|
|
|
return !Address.getValidationError(data, network, type); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Translates an address to other network |
|
|
|
* |
|
|
|
* @param {Address} address object - Bitcore address |
|
|
|
* @param {string} network - name of the network to translate the address to |
|
|
|
* |
|
|
|
* @returns {Address} Bitcore address object |
|
|
|
*/ |
|
|
|
Address.translate = function(address, toNetwork) { |
|
|
|
if (!Networks.get(toNetwork)) { |
|
|
|
throw new TypeError('Unknown network ' + toNetwork); |
|
|
|
} |
|
|
|
|
|
|
|
var orig = new Address(address); |
|
|
|
var origObj = orig.toObject(); |
|
|
|
|
|
|
|
origObj.network = toNetwork; |
|
|
|
return new Address.fromObject(origObj); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Returns true if an address is of pay to public key hash type |
|
|
|
* @return boolean |
|
|
|