Add error check on insight response for tx history
This commit is contained in:
parent
6a185c2191
commit
c2484b3b7a
|
@ -16,7 +16,7 @@ function BlockChainExplorer(opts) {
|
|||
var network = opts.network || 'livenet';
|
||||
var dfltUrl = network == 'livenet' ? 'https://insight.bitpay.com:443' :
|
||||
'https://test-insight.bitpay.com:443';
|
||||
var url = opts.url || dfltUrl;
|
||||
var url = opts.url || 'http://localhost:3003';
|
||||
|
||||
var url;
|
||||
switch (provider) {
|
||||
|
@ -44,9 +44,11 @@ function getTransactionsInsight(url, addresses, from, to, cb) {
|
|||
json: {
|
||||
addrs: [].concat(addresses).join(',')
|
||||
}
|
||||
}, function(err, res, body) {
|
||||
}, function(err, res, txs) {
|
||||
if (err || res.statusCode != 200) return cb(err || res);
|
||||
return cb(null, body);
|
||||
if (!_.isArray(txs) || _.compact(txs).length == 0) return cb(new Error('Could not retrieve transactions from blockchain'));
|
||||
|
||||
return cb(null, txs);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1231,7 +1231,9 @@ WalletService.prototype.startScan = function(opts, cb) {
|
|||
self.scan(opts, scanFinished);
|
||||
}, 100);
|
||||
|
||||
return cb(null, {started: true});
|
||||
return cb(null, {
|
||||
started: true
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue