Browse Source

Simplify script to address method

patch-2
Esteban Ordano 10 years ago
parent
commit
f74c7f3929
  1. 9
      lib/script/script.js

9
lib/script/script.js

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

Loading…
Cancel
Save