add scan after create/join with mnemonics

This commit is contained in:
Matias Alejo Garcia 2015-09-02 17:11:59 -03:00
commit 142a6bd03a
6 changed files with 76 additions and 10 deletions

View file

@ -87,7 +87,7 @@ angular.module('copayApp.controllers').controller('createController',
this._create = function (opts) {
$timeout(function() {
profileService.createWallet(opts, function(err, secret) {
profileService.createWallet(opts, function(err, secret, walletId) {
self.loading = false;
if (err) {
if (err == "Error creating wallet" && opts.extendedPublicKey) {
@ -100,7 +100,11 @@ angular.module('copayApp.controllers').controller('createController',
});
}
else {
go.walletHome();
if (opts.mnemonic && opts.n==1) {
$rootScope.$emit('Local/WalletImported', walletId);
} else {
go.walletHome();
}
}
});
}, 100);

View file

@ -65,7 +65,7 @@ angular.module('copayApp.controllers').controller('importController',
self.loading = true;
$timeout(function() {
profileService.importWalletMnemonic(words, opts, function(err, ret) {
profileService.importWalletMnemonic(words, opts, function(err, walletId) {
self.loading = false;
if (err) {
self.error = err;
@ -73,7 +73,6 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply();
});
}
return
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();

View file

@ -394,7 +394,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateTxHistory = function(skip) {
var fc = profileService.focusedClient;
if (!fc.isComplete()) return;
if (!fc || !fc.isComplete()) return;
if (!skip) {
self.txHistory = [];
}

View file

@ -153,6 +153,8 @@ angular.module('copayApp.controllers').controller('joinController',
var opts = {
secret: form.secret.$modelValue,
mnemonic: form.privateKey.$modelValue,
myName: form.myName.$modelValue
extendedPrivateKey: form.privateKey.$modelValue,
myName: form.myName.$modelValue
}
@ -189,7 +191,12 @@ angular.module('copayApp.controllers').controller('joinController',
return
}
$timeout(function() {
go.walletHome();
var fc = profileService.focusedClient;
if (opts.mnemonic && fc.isComplete()) {
$rootScope.$emit('Local/WalletImported', fc.credentials.walletId);
} else {
go.walletHome();
}
}, 2000);
});
}, 100);

View file

@ -236,7 +236,7 @@ angular.module('copayApp.services')
root.setAndStoreFocus(walletClient.credentials.walletId, function() {
storageService.storeProfile(root.profile, function(err) {
return cb(null, secret);
return cb(null, secret, walletClient.credentials.walletId);
});
});
})
@ -347,13 +347,10 @@ angular.module('copayApp.services')
var walletClient = bwcService.getClient();
$log.debug('Importing Wallet Mnemonic');
console.log('[profileService.js.340]', words, opts); //TODO
walletClient.importFromMnemonic(words, {
network: opts.networkName,
passphrase: opts.passphrase,
}, function(err) {
console.log('[profileService.js.342:err:]',err); //TODO
console.log('[profileService.js.341:walletClient:]',walletClient.credentials.credentials); //TODO
if (err)
return bwsError.cb(err, gettext('Could not import'), cb);