diff --git a/lib/primitives/mtx.js b/lib/primitives/mtx.js index f370dfd5..13ce237e 100644 --- a/lib/primitives/mtx.js +++ b/lib/primitives/mtx.js @@ -157,6 +157,7 @@ MTX.prototype.clone = function clone() { MTX.prototype.addInput = function addInput(options, index) { var input = new Input(); + input.mutable = true; if (options instanceof TX) @@ -240,9 +241,10 @@ MTX.prototype.scriptInput = function scriptInput(index, ring) { // Get the previous output's script prev = input.coin.script; - // This is easily the hardest part about building a transaction - // with segwit: figuring out where the redeem script and witness - // redeem scripts go. + // This is easily the hardest part about + // building a transaction with segwit: + // figuring out where the redeem script + // and witness redeem scripts go. if (prev.isScripthash()) { redeem = ring.getRedeem(prev.get(1)); @@ -262,6 +264,8 @@ MTX.prototype.scriptInput = function scriptInput(index, ring) { return false; input.witness.push(prev.toRaw()); + input.witness.compile(); + input.script.push(redeem.toRaw()); input.script.compile(); @@ -308,7 +312,7 @@ MTX.prototype.scriptInput = function scriptInput(index, ring) { return false; input.witness.push(redeem.toRaw()); - input.script.compile(); + input.witness.compile(); return true; } @@ -320,7 +324,7 @@ MTX.prototype.scriptInput = function scriptInput(index, ring) { if (!this.scriptVector(prev, input.witness, ring)) return false; - input.script.compile(); + input.witness.compile(); return true; }