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