Merge pull request #433 from isocolsky/fix/2-step

Fix 2-step balance computation
This commit is contained in:
Matias Alejo Garcia 2016-01-13 12:12:48 -03:00
commit 46c92e2248
1 changed files with 9 additions and 7 deletions

View File

@ -614,8 +614,8 @@ WalletService.prototype.joinWallet = function(opts, cb) {
}
if (_.find(wallet.copayers, {
xPubKey: opts.xPubKey
})) return cb(Errors.COPAYER_IN_WALLET);
xPubKey: opts.xPubKey
})) return cb(Errors.COPAYER_IN_WALLET);
if (wallet.copayers.length == wallet.n) return cb(Errors.WALLET_FULL);
@ -708,8 +708,8 @@ WalletService.prototype._canCreateAddress = function(ignoreMaxGap, cb) {
isChange: true
}), Defaults.MAX_MAIN_ADDRESS_GAP);
if (latestAddresses.length < Defaults.MAX_MAIN_ADDRESS_GAP || _.any(latestAddresses, {
hasActivity: true
})) return cb(null, true);
hasActivity: true
})) return cb(null, true);
var bc = self._getBlockchainExplorer(latestAddresses[0].network);
var activityFound = false;
@ -1059,9 +1059,9 @@ WalletService.prototype._getActiveAddresses = function(cb) {
var result = _.union(active, recent);
var index = _.indexBy(allAddresses, 'address');
result = _.map(result, function(r) {
result = _.compact(_.map(result, function(r) {
return index[r];
});
}));
return cb(null, result);
});
});
@ -1101,7 +1101,9 @@ WalletService.prototype.getBalance = function(opts, cb) {
if (err) return;
if (!_.isEqual(partialBalance, fullBalance)) {
log.debug('Cache miss: balance in active addresses differs from final balance');
self._notify('BalanceUpdated', fullBalance);
self._notify('BalanceUpdated', fullBalance, {
isGlobal: true
});
}
});
}, 1);