From 80df5e2e3125ff51a4c4c9fa7cc6989c56985b00 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 13 Jul 2015 16:37:21 -0300 Subject: [PATCH] fix insight response parsing with from/to are used --- lib/blockchainexplorers/insight.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/blockchainexplorers/insight.js b/lib/blockchainexplorers/insight.js index f11e901..c392b21 100644 --- a/lib/blockchainexplorers/insight.js +++ b/lib/blockchainexplorers/insight.js @@ -87,6 +87,10 @@ Insight.prototype.getTransactions = function(addresses, from, to, cb) { request(args, function(err, res, txs) { if (err || res.statusCode != 200) return cb(err || res); + + if (_.isObject(txs) && txs.items) + txs = txs.items; + // NOTE: Whenever Insight breaks communication with bitcoind, it returns invalid data but no error code. if (!_.isArray(txs) || (txs.length != _.compact(txs).length)) return cb(new Error('Could not retrieve transactions from blockchain. Request was:' + JSON.stringify(args)));