Simplify script to address method

This commit is contained in:
Esteban Ordano 2014-12-30 16:16:34 -03:00
parent ffca4cfb6f
commit f74c7f3929
1 changed files with 3 additions and 6 deletions

View File

@ -707,13 +707,10 @@ Script.fromAddress = function(address) {
Script.prototype.toAddress = function(network) {
network = Networks.get(network);
$.checkArgument(network, 'Must provide a network');
if (this.isPublicKeyHashOut()) {
return new Address(this.getData(), network, Address.PayToPublicKeyHash);
} else if (this.isScriptHashOut()) {
return new Address(this.getData(), network, Address.PayToScriptHash);
} else {
throw new Error('The script type needs to be PayToPublicKeyHash or PayToScriptHash');
if (this.isPublicKeyHashOut() || this.isScriptHashOut()) {
return new Address(this, network);
}
throw new Error('The script type needs to be PayToPublicKeyHash or PayToScriptHash');
};
/**