fix wallet lock - add tabs in export wallet
This commit is contained in:
parent
b802171746
commit
45d44a927b
3 changed files with 146 additions and 86 deletions
|
|
@ -23,8 +23,7 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
|
||||
handleEncryptedWallet(fc, function(err) {
|
||||
if (err) {
|
||||
$scope.error = bwsError.msg(err, gettext('Could not decrypt'));
|
||||
$log.warn('Error decrypting credentials:', $scope.error);
|
||||
go.path(prevState);
|
||||
return;
|
||||
}
|
||||
$scope.credentialsEncrypted = false;
|
||||
|
|
@ -69,10 +68,13 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
};
|
||||
|
||||
$scope.goBack = function() {
|
||||
walletService.lock(fc);
|
||||
go.path(prevState || 'walletHome');
|
||||
};
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
walletService.lock(fc);
|
||||
});
|
||||
|
||||
$scope.goToStep = function(n) {
|
||||
if (n == 1)
|
||||
$scope.initFlow();
|
||||
|
|
|
|||
|
|
@ -1,39 +1,88 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('exportController',
|
||||
function($scope, $timeout, $log, backupService, fingerprintService, configService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog) {
|
||||
function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, fingerprintService, configService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog) {
|
||||
var prevState;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
||||
$scope.error = null;
|
||||
$scope.success = null;
|
||||
var fc = profileService.focusedClient;
|
||||
$scope.isEncrypted = fc.isPrivKeyEncrypted();
|
||||
$scope.touchidSuccess = null;
|
||||
$scope.touchidEnabled = null;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.error = null;
|
||||
|
||||
$scope.init = function(state) {
|
||||
if (!isCordova) return;
|
||||
|
||||
var config = configService.getSync();
|
||||
var touchidAvailable = fingerprintService.isAvailable();
|
||||
var touchidEnabled = $scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null;
|
||||
|
||||
if (!touchidAvailable || !touchidEnabled) return;
|
||||
$scope.QROpts = false;
|
||||
prevState = state || 'walletHome';
|
||||
|
||||
fingerprintService.check(fc, function(err) {
|
||||
if (err)
|
||||
go.path(state || 'walletHome');
|
||||
if (err) {
|
||||
go.path(prevState);
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.touchidSuccess = true;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
handleEncryptedWallet(fc, function(err) {
|
||||
if (err) {
|
||||
go.path(prevState);
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.exportWalletInfo = encodeWalletInfo();
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
walletService.lock(fc);
|
||||
});
|
||||
|
||||
function handleEncryptedWallet(client, cb) {
|
||||
if (!walletService.isEncrypted(client)) {
|
||||
$scope.credentialsEncrypted = false;
|
||||
return cb();
|
||||
}
|
||||
|
||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
||||
if (err) return cb(err);
|
||||
return cb(walletService.unlock(client, password));
|
||||
});
|
||||
};
|
||||
|
||||
function encodeWalletInfo() {
|
||||
var c = fc.credentials;
|
||||
var encodingType = {
|
||||
mnemonic: 1,
|
||||
xpriv: 2,
|
||||
xpub: 3
|
||||
};
|
||||
var info;
|
||||
|
||||
if (c.canSign()) {
|
||||
if (c.mnemonic) {
|
||||
info = {
|
||||
type: encodingType.mnemonic,
|
||||
data: c.mnemonic
|
||||
}
|
||||
} else {
|
||||
info = {
|
||||
type: encodingType.xpriv,
|
||||
data: c.xPrivKey
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info = {
|
||||
type: encodingType.xpub,
|
||||
data: c.xPubKey
|
||||
}
|
||||
}
|
||||
|
||||
var code = info.type + c.network.charAt(0).toLowerCase() + info.data;
|
||||
return code;
|
||||
};
|
||||
|
||||
$scope.downloadWalletBackup = function() {
|
||||
$scope.getAddressbook(function(err, localAddressBook) {
|
||||
if (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue