|
|
@ -876,7 +876,7 @@ WalletService.prototype._getUtxos = function(addresses, cb) { |
|
|
|
var networkName = Bitcore.Address(addresses[0]).toObject().network; |
|
|
|
|
|
|
|
var bc = self._getBlockchainExplorer(networkName); |
|
|
|
bc.getUnspentUtxos(addresses, function(err, utxos) { |
|
|
|
bc.getUtxos(addresses, function(err, utxos) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
var utxos = _.map(utxos, function(utxo) { |
|
|
@ -1018,7 +1018,7 @@ WalletService.prototype._getBalanceFromAddresses = function(addresses, cb) { |
|
|
|
|
|
|
|
// Compute balance by address
|
|
|
|
var byAddress = {}; |
|
|
|
_.each(_.indexBy(utxos, 'address'), function(value, key) { |
|
|
|
_.each(_.indexBy(_.sortBy(utxos, 'address'), 'address'), function(value, key) { |
|
|
|
byAddress[key] = { |
|
|
|
address: key, |
|
|
|
path: value.path, |
|
|
@ -1121,7 +1121,6 @@ WalletService.prototype.getBalance = function(opts, cb) { |
|
|
|
if (nbAddresses < Defaults.TWO_STEP_BALANCE_THRESHOLD) { |
|
|
|
return self._getBalanceOneStep(opts, cb); |
|
|
|
} |
|
|
|
|
|
|
|
self._getActiveAddresses(function(err, activeAddresses) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!_.isArray(activeAddresses)) { |
|
|
@ -1135,7 +1134,7 @@ WalletService.prototype.getBalance = function(opts, cb) { |
|
|
|
self._getBalanceOneStep(opts, function(err, fullBalance) { |
|
|
|
if (err) return; |
|
|
|
if (!_.isEqual(partialBalance, fullBalance)) { |
|
|
|
log.debug('Cache miss: balance in active addresses differs from final balance'); |
|
|
|
log.info('Balance in active addresses differs from final balance'); |
|
|
|
self._notify('BalanceUpdated', fullBalance, { |
|
|
|
isGlobal: true |
|
|
|
}); |
|
|
|