Merge pull request #168 from cmgustavo/ref/design-44

Return cached address while BWS returns main address GAP reached
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-27 09:55:10 -03:00 committed by GitHub
commit 510ceddaac
2 changed files with 7 additions and 23 deletions

View file

@ -37,10 +37,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$timeout(function() {
walletService.getAddress($scope.wallet, forceNew, function(err, addr) {
$scope.generatingAddress = false;
if (err || lodash.isEmpty(addr)) {
popupService.showAlert(gettextCatalog.getString('Error'), err || gettextCatalog.getString('Address is empty'));
return;
}
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.addr = addr;
$scope.$apply();
});

View file

@ -792,29 +792,16 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
root.getAddress = function(wallet, forceNew, cb) {
var firstStep;
if (forceNew) {
firstStep = storageService.clearLastAddress;
} else {
firstStep = function(walletId, cb) {
return cb();
};
}
firstStep(wallet.id, function(err) {
storageService.getLastAddress(wallet.id, function(err, addr) {
if (err) return cb(err);
storageService.getLastAddress(wallet.id, function(err, addr) {
if (err) return cb(err);
if (!forceNew && addr) return cb(null, addr);
if (addr) return cb(null, addr);
createAddress(wallet, function(err, addr) {
createAddress(wallet, function(err, _addr) {
if (err) return cb(err, addr);
storageService.storeLastAddress(wallet.id, _addr, function() {
if (err) return cb(err);
storageService.storeLastAddress(wallet.id, addr, function() {
if (err) return cb(err);
return cb(null, addr);
});
return cb(null, _addr);
});
});
});