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