diff --git a/lib/server.js b/lib/server.js index 973e4eb..c7b511f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -474,7 +474,7 @@ WalletService.prototype.getWalletFromIdentifier = function(opts, cb) { nextCoinNetwork(!!walletId); }); }); - }, function(walletId) { + }, function() { if (!walletId) return cb(); return self.storage.fetchWallet(walletId, cb); }); @@ -932,6 +932,7 @@ WalletService.prototype._canCreateAddress = function(ignoreMaxGap, cb) { })) return cb(null, true); var bc = self._getBlockchainExplorer(latestAddresses[0].coin, latestAddresses[0].network); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); var activityFound = false; var i = latestAddresses.length; async.whilst(function() { @@ -1079,6 +1080,7 @@ WalletService.prototype._getUtxos = function(coin, addresses, cb) { var networkName = Bitcore.Address(addresses[0]).toObject().network; var bc = self._getBlockchainExplorer(coin, networkName); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); bc.getUtxos(addresses, function(err, utxos) { if (err) return cb(err); @@ -1508,6 +1510,7 @@ WalletService.prototype._sampleFeeLevels = function(coin, network, points, cb) { var self = this; var bc = self._getBlockchainExplorer(coin, network); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); bc.estimateFee(points, function(err, result) { if (err) { log.error('Error estimating fee', err); @@ -2405,6 +2408,7 @@ WalletService.prototype.removePendingTx = function(opts, cb) { WalletService.prototype._broadcastRawTx = function(coin, network, raw, cb) { var bc = this._getBlockchainExplorer(coin, network); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); bc.broadcast(raw, function(err, txid) { if (err) return cb(err); return cb(null, txid); @@ -2438,6 +2442,7 @@ WalletService.prototype.broadcastRawTx = function(opts, cb) { WalletService.prototype._checkTxInBlockchain = function(txp, cb) { if (!txp.txid) return cb(); var bc = this._getBlockchainExplorer(txp.coin, txp.network); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); bc.getTransaction(txp.txid, function(err, tx) { if (err) return cb(err); return cb(null, !!tx); @@ -2800,6 +2805,7 @@ WalletService.prototype._getBlockchainHeight = function(coin, network, cb) { function fetchFromBlockchain(cb) { var bc = self._getBlockchainExplorer(coin, network); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); bc.getBlockchainHeight(function(err, height) { if (!err && height > 0) { cache.current = height; @@ -2991,6 +2997,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) { var addressStrs = _.pluck(addresses, 'address'); var bc = self._getBlockchainExplorer(wallet.coin, wallet.network); + if (!bc) return next(new Error('Could not get blockchain explorer instance')); bc.getTransactions(addressStrs, from, to, function(err, rawTxs, total) { if (err) return next(err); @@ -3142,6 +3149,7 @@ WalletService.prototype.scan = function(opts, cb) { function checkActivity(wallet, address, cb) { var bc = self._getBlockchainExplorer(wallet.coin, wallet.network); + if (!bc) return cb(new Error('Could not get blockchain explorer instance')); bc.getAddressActivity(address, cb); };