From b452f76250173a410f8a5cad041cd85736a4aef9 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 14 Jul 2015 20:33:23 -0300 Subject: [PATCH] filter out utxo without scriptpubkey --- app/models/Address.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/Address.js b/app/models/Address.js index f34c3e1..780daf7 100644 --- a/app/models/Address.js +++ b/app/models/Address.js @@ -1,6 +1,7 @@ 'use strict'; var imports = require('soop').imports(); +var _ = require('lodash'); var async = require('async'); var bitcore = require('bitcore'); var BitcoreAddress = bitcore.Address; @@ -183,7 +184,9 @@ Address.prototype.update = function(next, opts) { return !x.spentTxId; }); tDb.fillScriptPubKey(txOut, function() { - self.unspent = txOut.map(function(x) { + //_.filter will filterout unspend without scriptPubkey + //(probably from double spends) + self.unspent = _.filter(txOut.map(function(x) { return { address: self.addrStr, txid: x.txid, @@ -194,7 +197,7 @@ Address.prototype.update = function(next, opts) { confirmations: x.isConfirmedCached ? (config.safeConfirmations) : x.confirmations, confirmationsFromCache: !!x.isConfirmedCached, }; - }); + }), 'scriptPubKey');; return next(); }); } else {