outputScript() consistency.

This commit is contained in:
Christopher Jeffrey 2015-12-10 18:02:47 -08:00
parent 1caa0804d9
commit 5c1606985a

View File

@ -301,21 +301,25 @@ TX.prototype.scriptSig = function(input, key, pub, type) {
return input.script; return input.script;
}; };
TX.prototype.output = function output(output, value) { TX.prototype.output = function output(options, value) {
if (output instanceof bcoin.wallet) if (options instanceof bcoin.wallet)
output = output.getAddress(); options = options.getAddress();
if (typeof output === 'string') { if (typeof options === 'string') {
output = { options = {
address: output, address: options,
value: value value: value
}; };
} }
this.outputs.push({ var output = {
value: new bn(output.value), value: new bn(options.value),
script: this.scriptOutput(output) script: options.script ? options.script.slice() : []
}); };
this.outputs.push(output);
this.scriptOutput(output, options);
return this; return this;
}; };
@ -323,8 +327,10 @@ TX.prototype.output = function output(output, value) {
// compat // compat
TX.prototype.out = TX.prototype.output; TX.prototype.out = TX.prototype.output;
TX.prototype.scriptOutput = function(options) { TX.prototype.scriptOutput = function(output, options) {
var script = options.script ? options.script.slice() : []; options = options || output;
var script = output.script ? output.script.slice() : [];
if (Array.isArray(options.keys || options.address)) { if (Array.isArray(options.keys || options.address)) {
// Raw multisig transaction // Raw multisig transaction
@ -391,7 +397,7 @@ TX.prototype.scriptOutput = function(options) {
script.redeem = redeem; script.redeem = redeem;
} }
return script; output.script = script;
}; };
TX.prototype.getSubscript = function getSubscript(index) { TX.prototype.getSubscript = function getSubscript(index) {