From 78b84fc4665df6e71cca9d20333c778d3e77ce0a Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 2 Nov 2014 19:07:43 -0300 Subject: [PATCH] filter unspent --- js/models/Wallet.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/models/Wallet.js b/js/models/Wallet.js index 464732d8b..5d038277e 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -2172,11 +2172,17 @@ Wallet.prototype.getBalance = function(cb) { var balanceByAddr = {}; var COIN = coinUtil.COIN; - this.getUnspent(function(err, safeUnspent, unspent) { + this.getUnspent(function(err, safeUnspent, unspentRaw) { if (err) { return cb(err); } + // This filter out possible broken unspent, as reported on + // https://github.com/bitpay/copay/issues/1585 + // and later gitter conversation. + + var unspent = _.filter(unspentRaw, 'scriptPubKey'); + for (var i = 0; i < unspent.length; i++) { var u = unspent[i]; var amt = u.amount * COIN;