creates a wallet address by default for all non multisig wallets

This commit is contained in:
Kadir Sekha 2018-02-06 13:49:58 -04:00
commit f8135f3bd3
2 changed files with 69 additions and 32 deletions

View file

@ -235,10 +235,11 @@ angular.module('copayApp.controllers').controller('createController',
ongoingProcess.set('creatingWallet', true); ongoingProcess.set('creatingWallet', true);
$timeout(function() { $timeout(function() {
profileService.createWallet(opts, function(err, client) { profileService.createWallet(opts, function(err, client) {
function finish(error) {
ongoingProcess.set('creatingWallet', false); ongoingProcess.set('creatingWallet', false);
if (err) { if (error) {
$log.warn(err); $log.warn(error);
popupService.showAlert(gettextCatalog.getString('Error'), err); popupService.showAlert(gettextCatalog.getString('Error'), error);
return; return;
} }
@ -266,6 +267,17 @@ angular.module('copayApp.controllers').controller('createController',
firebaseEventsService.logEvent('wallet_created', { coin: opts.coin }); firebaseEventsService.logEvent('wallet_created', { coin: opts.coin });
$state.go('tabs.home'); $state.go('tabs.home');
} }
}
if (opts.n >= 2) {
finish(err);
} else {
ongoingProcess.set('generatingNewAddress', true);
walletService.getAddress(client, true, function(e, addr) {
ongoingProcess.set('generatingNewAddress', false);
finish(e);
});
}
}); });
}, 300); }, 300);
} }

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tourController', angular.module('copayApp.controllers').controller('tourController',
function($scope, $state, $log, $timeout, $filter, ongoingProcess, profileService, rateService, popupService, gettextCatalog, startupService, storageService) { function($scope, $state, $log, $timeout, $filter, ongoingProcess, profileService, rateService, popupService, gettextCatalog, startupService, storageService, walletService, $q) {
$scope.data = { $scope.data = {
index: 0 index: 0
@ -60,17 +60,42 @@ angular.module('copayApp.controllers').controller('tourController',
} }
}, 2000); }, 2000);
}; };
ongoingProcess.set('creatingWallet', false); ongoingProcess.set('creatingWallet', false);
var bchWallet = walletClients[0]; var bchWallet = walletClients[0];
var btcWallet = walletClients[1]; var btcWallet = walletClients[1];
var bchWalletId = bchWallet.credentials.walletId; var bchWalletId = bchWallet.credentials.walletId;
var btcWalletId = btcWallet.credentials.walletId; var btcWalletId = btcWallet.credentials.walletId;
function createAddressPromise(wallet) {
return $q(function(resolve, reject) {
walletService.getAddress(wallet, true, function(e, addr) {
if (e) reject(e);
resolve(addr);
});
});
}
function goToCollectEmail() {
$state.go('onboarding.collectEmail', { $state.go('onboarding.collectEmail', {
bchWalletId: bchWalletId, bchWalletId: bchWalletId,
btcWalletId: btcWalletId btcWalletId: btcWalletId
}); });
}
var bchAddressPromise = createAddressPromise(bchWallet);
var btcAddressPromise = createAddressPromise(btcWallet);
ongoingProcess.set('generatingNewAddress', true);
$q.all([bchAddressPromise, btcAddressPromise]).then(function(addresses) {
ongoingProcess.set('generatingNewAddress', false);
goToCollectEmail();
}, function(e) {
ongoingProcess.set('generatingNewAddress', false);
$log.warn(e);
popupService.showAlert(gettextCatalog.getString('Error'), e);
goToCollectEmail();
});
}); });
}, 300); }, 300);
}; };