From f74c7f3929f7055bc559ae9253788d110febb815 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Tue, 30 Dec 2014 16:16:34 -0300 Subject: [PATCH] Simplify script to address method --- lib/script/script.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/script/script.js b/lib/script/script.js index f72bad1..f7820cb 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -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'); }; /**