diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 15cb69ce..87520a37 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -219,10 +219,10 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) { inputs = inputs || tx.inputs; // Add signature script to each input - inputs.forEach(function(input, i) { + inputs = inputs.filter(function(input, i) { // Filter inputs that this wallet own if (!input.out.tx || !this.ownOutput(input.out.tx)) - return; + return false; var s = input.out.tx.getSubscript(input.out.index); var hash = tx.subscriptHash(off + i, s, type); @@ -231,11 +231,13 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) { if (bcoin.script.isPubkeyhash(s)) { input.script = [ signature, pub ]; - return; + return true; } // Multisig input.script = [ [], signature ]; + + return true; }, this); return inputs.length;