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
|
|
@ -5,23 +5,30 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content preferences" ng-controller="exportController" ng-init="init(index.prevState)">
|
<div class="content preferences" ng-controller="exportController" ng-init="init(index.prevState)">
|
||||||
<h4></h4>
|
<div class="create-tab small-only-text-center">
|
||||||
<div ng-show="!backupWalletPlainText">
|
<div class="row">
|
||||||
|
<div class="tab-container small-6 medium-3 large-2"
|
||||||
|
ng-class="{'selected':!exportQR}"
|
||||||
|
ng-style="{'border-color':!exportQR ? index.backgroundColor: 'inherit'}"
|
||||||
|
ng-click="exportQR = false">
|
||||||
|
<a href ng-style="{'color':!exportQR ? index.backgroundColor: 'inherit'}" translate>File/Text</a>
|
||||||
|
</div>
|
||||||
|
<div class="tab-container small-6 medium-3 large-2"
|
||||||
|
ng-class="{'selected':exportQR}"
|
||||||
|
ng-style="{'border-color':exportQR ? index.backgroundColor: 'inherit'}"
|
||||||
|
ng-click="exportQR = true">
|
||||||
|
<a href ng-style="{'color':exportQR ? index.backgroundColor: 'inherit'}" translate>QR Code</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-show="!backupWalletPlainText && !exportQR">
|
||||||
<div class="text-warning size-14 m20b" ng-show="error">
|
<div class="text-warning size-14 m20b" ng-show="error">
|
||||||
<i class="fi-alert size-12"></i>
|
<i class="fi-alert size-12"></i>
|
||||||
<span translate>Failed to export</span>
|
<span translate>Failed to export</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<form>
|
||||||
<div class="columns">
|
|
||||||
<div class="text-warning size-14 m20b" ng-show="isEncrypted">
|
|
||||||
<i class="fi-alert size-12"></i>
|
|
||||||
<span translate> A spending password is set for this wallet. Exporting keeps the spending password in the export archive.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form ng-hide="touchidEnabled && !touchidSuccess">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<label for="password" translate>Set up a password </label>
|
<label for="password" translate>Set up a password </label>
|
||||||
|
|
@ -52,7 +59,6 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="box-notification" ng-show="noSign">
|
<div class="box-notification" ng-show="noSign">
|
||||||
<span class="text-warning size-14">
|
<span class="text-warning size-14">
|
||||||
<i class="fi-alert"></i>
|
<i class="fi-alert"></i>
|
||||||
|
|
@ -67,14 +73,14 @@
|
||||||
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
|
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
|
||||||
ng-disabled="(!password || password != repeatpassword)"
|
ng-disabled="(!password || password != repeatpassword)"
|
||||||
ng-style="{'background-color':index.backgroundColor}"
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
ng-show="!index.isSafari && !index.isCordova"><i class="fi-download"></i>
|
ng-show="!isSafari && !isCordova"><i class="fi-download"></i>
|
||||||
<span translate>Download</span></button>
|
<span translate>Download</span></button>
|
||||||
<button class="black round expand m20t" ng-click="viewWalletBackup()"
|
<button class="black round expand m20t" ng-click="viewWalletBackup()"
|
||||||
ng-disabled="(!password || password != repeatpassword)"
|
ng-disabled="(!password || password != repeatpassword)"
|
||||||
ng-style="{'background-color':index.backgroundColor}"
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
ng-show="index.isSafari && !index.isCordova"><i class="fi-eye"></i>
|
ng-show="isSafari && !isCordova"><i class="fi-eye"></i>
|
||||||
<span translate>View</span></button>
|
<span translate>View</span></button>
|
||||||
<div ng-show="index.isCordova">
|
<div ng-show="isCordova">
|
||||||
<h4 translate>Export options</h4>
|
<h4 translate>Export options</h4>
|
||||||
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
|
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
|
||||||
ng-style="{'background-color':index.backgroundColor}"
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
|
|
@ -87,7 +93,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="containter text-center p50t" ng-show="exportQR">
|
||||||
|
<qrcode size="220" version="7" error-correction-level="M" data="{{exportWalletInfo}}"></qrcode>
|
||||||
|
<span translate></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" ng-show="backupWalletPlainText">
|
<div class="row" ng-show="backupWalletPlainText">
|
||||||
|
|
@ -102,6 +112,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="extra-margin-bottom"></div>
|
<div class="extra-margin-bottom"></div>
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
|
|
||||||
handleEncryptedWallet(fc, function(err) {
|
handleEncryptedWallet(fc, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$scope.error = bwsError.msg(err, gettext('Could not decrypt'));
|
go.path(prevState);
|
||||||
$log.warn('Error decrypting credentials:', $scope.error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.credentialsEncrypted = false;
|
$scope.credentialsEncrypted = false;
|
||||||
|
|
@ -69,10 +68,13 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.goBack = function() {
|
$scope.goBack = function() {
|
||||||
walletService.lock(fc);
|
|
||||||
go.path(prevState || 'walletHome');
|
go.path(prevState || 'walletHome');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.$on('$destroy', function() {
|
||||||
|
walletService.lock(fc);
|
||||||
|
});
|
||||||
|
|
||||||
$scope.goToStep = function(n) {
|
$scope.goToStep = function(n) {
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
$scope.initFlow();
|
$scope.initFlow();
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,86 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('exportController',
|
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 isWP = platformInfo.isWP;
|
||||||
var isAndroid = platformInfo.isAndroid;
|
var isAndroid = platformInfo.isAndroid;
|
||||||
var isCordova = platformInfo.isCordova;
|
|
||||||
|
|
||||||
$scope.error = null;
|
|
||||||
$scope.success = null;
|
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
$scope.isEncrypted = fc.isPrivKeyEncrypted();
|
$scope.isEncrypted = fc.isPrivKeyEncrypted();
|
||||||
$scope.touchidSuccess = null;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
$scope.touchidEnabled = null;
|
$scope.isSafari = platformInfo.isSafari;
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
|
|
||||||
$scope.init = function(state) {
|
$scope.init = function(state) {
|
||||||
if (!isCordova) return;
|
$scope.QROpts = false;
|
||||||
|
prevState = state || 'walletHome';
|
||||||
var config = configService.getSync();
|
|
||||||
var touchidAvailable = fingerprintService.isAvailable();
|
|
||||||
var touchidEnabled = $scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null;
|
|
||||||
|
|
||||||
if (!touchidAvailable || !touchidEnabled) return;
|
|
||||||
|
|
||||||
fingerprintService.check(fc, function(err) {
|
fingerprintService.check(fc, function(err) {
|
||||||
if (err)
|
if (err) {
|
||||||
go.path(state || 'walletHome');
|
go.path(prevState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.touchidSuccess = true;
|
handleEncryptedWallet(fc, function(err) {
|
||||||
|
if (err) {
|
||||||
|
go.path(prevState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.exportWalletInfo = encodeWalletInfo();
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 10);
|
}, 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.downloadWalletBackup = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue