Merge pull request #277 from matiu/bug/insight-response

fix insight response parsing with from/to are used
This commit is contained in:
Matias Alejo Garcia 2015-07-13 18:07:16 -03:00
commit 8403373ed3
1 changed files with 4 additions and 0 deletions

View File

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