|
|
@ -116,31 +116,6 @@ function TransactionBuilder(opts) { |
|
|
|
|
|
|
|
TransactionBuilder.FEE_PER_1000B_SAT = FEE_PER_1000B_SAT; |
|
|
|
|
|
|
|
/* |
|
|
|
* scriptForAddress |
|
|
|
* |
|
|
|
* Returns a scriptPubKey for the given address type |
|
|
|
*/ |
|
|
|
|
|
|
|
TransactionBuilder.scriptForAddress = function(addressString) { |
|
|
|
|
|
|
|
var livenet = networks.livenet; |
|
|
|
var testnet = networks.testnet; |
|
|
|
var address = new Address(addressString); |
|
|
|
|
|
|
|
var version = address.version(); |
|
|
|
var script; |
|
|
|
if (version === livenet.addressVersion || version === testnet.addressVersion) |
|
|
|
script = Script.createPubKeyHashOut(address.payload()); |
|
|
|
else if (version === livenet.P2SHVersion || version === testnet.P2SHVersion) |
|
|
|
script = Script.createP2SH(address.payload()); |
|
|
|
else |
|
|
|
throw new Error('invalid output address'); |
|
|
|
|
|
|
|
return script; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TransactionBuilder._scriptForPubkeys = function(out) { |
|
|
|
|
|
|
|
var l = out.pubkeys.length; |
|
|
@ -156,7 +131,7 @@ TransactionBuilder._scriptForPubkeys = function(out) { |
|
|
|
TransactionBuilder._scriptForOut = function(out) { |
|
|
|
var ret; |
|
|
|
if (out.address) |
|
|
|
ret = this.scriptForAddress(out.address); |
|
|
|
ret = new Address(out.address).getScriptPubKey(); |
|
|
|
else if (out.pubkeys || out.nreq || out.nreq > 1) |
|
|
|
ret = this._scriptForPubkeys(out); |
|
|
|
else |
|
|
|