filter unspent

This commit is contained in:
Matias Alejo Garcia 2014-11-02 19:07:43 -03:00
parent a778cc71a1
commit 78b84fc466
1 changed files with 7 additions and 1 deletions

View File

@ -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;