From 0efe2e2021ec841e2ae5f36986bcf1a87965f38a Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 10 May 2014 10:39:20 +0400 Subject: [PATCH] script: fix verification of multisig --- lib/bcoin/script.js | 2 +- lib/bcoin/tx.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index ab4d6117..0c10fcb1 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -186,7 +186,7 @@ script.execute = function execute(s, stack, tx) { // Get signatures var succ = 0; - for (var i = 0, j = 0; i < m, j < n; i++) { + for (var i = 0, j = 0; i < m && j < n; i++) { var sig = stack.pop(); var type = sig[sig.length - 1]; if (type !== 1) diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 9f2c918c..6abf7c4c 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -78,9 +78,6 @@ TX.prototype.input = function input(i, index) { seq: i.seq === undefined ? 0xffffffff : i.seq }; - if (input.out.tx) - this.funds.iadd(input.out.tx.outputs[input.out.index].value); - // Try modifying existing input first for (var i = 0; i < this.inputs.length; i++) { var ex = this.inputs[i]; @@ -92,8 +89,11 @@ TX.prototype.input = function input(i, index) { ex.script = input.script.length ? input.script : ex.script; break; } - if (i === this.inputs.length) + if (i === this.inputs.length) { this.inputs.push(input); + if (input.out.tx) + this.funds.iadd(input.out.tx.outputs[input.out.index].value); + } return this; };