diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index cd4106c3..15cb69ce 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -215,14 +215,15 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) { if (!off) off = 0; - // Filter inputs that this wallet own - var inputs = inputs || tx.inputs.filter(function(input) { - return input.out.tx && this.ownOutput(input.out.tx); - }, this); var pub = this.getPublicKey(); + inputs = inputs || tx.inputs; // Add signature script to each input inputs.forEach(function(input, i) { + // Filter inputs that this wallet own + if (!input.out.tx || !this.ownOutput(input.out.tx)) + return; + var s = input.out.tx.getSubscript(input.out.index); var hash = tx.subscriptHash(off + i, s, type); var signature = bcoin.ecdsa.sign(hash, this.key).toDER();