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,89 +5,99 @@
|
|||
</div>
|
||||
|
||||
<div class="content preferences" ng-controller="exportController" ng-init="init(index.prevState)">
|
||||
<h4></h4>
|
||||
<div ng-show="!backupWalletPlainText">
|
||||
<div class="text-warning size-14 m20b" ng-show="error">
|
||||
<i class="fi-alert size-12"></i>
|
||||
<span translate>Failed to export</span>
|
||||
<div class="create-tab small-only-text-center">
|
||||
<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">
|
||||
<i class="fi-alert size-12"></i>
|
||||
<span translate>Failed to export</span>
|
||||
</div>
|
||||
|
||||
<form>
|
||||
<div class="row">
|
||||
<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>
|
||||
<label for="password" translate>Set up a password </label>
|
||||
<div class="input">
|
||||
<input type="password" class="form-control" placeholder="{{'Your password'|translate}}" name="password" ng-model="password">
|
||||
</div>
|
||||
|
||||
<label for="password" translate>Repeat the password</label>
|
||||
<div class="input">
|
||||
<input type="password" class="form-control" placeholder="{{'Repeat password'|translate}}" name="password" ng-model="repeatpassword">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form ng-hide="touchidEnabled && !touchidSuccess">
|
||||
<div class="row">
|
||||
<div class="columns">
|
||||
<label for="password" translate>Set up a password </label>
|
||||
<div class="input">
|
||||
<input type="password" class="form-control" placeholder="{{'Your password'|translate}}" name="password" ng-model="password">
|
||||
</div>
|
||||
<h4></h4>
|
||||
|
||||
<label for="password" translate>Repeat the password</label>
|
||||
<div class="input">
|
||||
<input type="password" class="form-control" placeholder="{{'Repeat password'|translate}}" name="password" ng-model="repeatpassword">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<ion-toggle ng-model="noSignEnabled" toggle-class="toggle-balanced" class="r0">
|
||||
<span class="toggle-label" translate>Do not include private key</span>
|
||||
</ion-toggle>
|
||||
|
||||
<h4></h4>
|
||||
|
||||
<ion-toggle ng-model="noSignEnabled" toggle-class="toggle-balanced" class="r0">
|
||||
<span class="toggle-label" translate>Do not include private key</span>
|
||||
</ion-toggle>
|
||||
|
||||
<div class="box-notification" ng-show="!index.canSign">
|
||||
<span class="text-warning size-14">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
|
||||
</span>
|
||||
<div class="box-notification" ng-show="!index.canSign">
|
||||
<span class="text-warning size-14">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="box-notification" ng-show="noSign">
|
||||
<span class="text-warning size-14">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
WARNING: Not including the private key allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
|
||||
</span>
|
||||
<div class="box-notification" ng-show="noSign">
|
||||
<span class="text-warning size-14">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
WARNING: Not including the private key allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="columns">
|
||||
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
|
||||
ng-disabled="(!password || password != repeatpassword)"
|
||||
<div class="row">
|
||||
<div class="columns">
|
||||
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
|
||||
ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-show="!isSafari && !isCordova"><i class="fi-download"></i>
|
||||
<span translate>Download</span></button>
|
||||
<button class="black round expand m20t" ng-click="viewWalletBackup()"
|
||||
ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-show="isSafari && !isCordova"><i class="fi-eye"></i>
|
||||
<span translate>View</span></button>
|
||||
<div ng-show="isCordova">
|
||||
<h4 translate>Export options</h4>
|
||||
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-show="!index.isSafari && !index.isCordova"><i class="fi-download"></i>
|
||||
<span translate>Download</span></button>
|
||||
<button class="black round expand m20t" ng-click="viewWalletBackup()"
|
||||
ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-click="copyWalletBackup()"><i class="fi-clipboard-pencil"></i>
|
||||
<span translate>Copy to clipboard</span></button>
|
||||
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-show="index.isSafari && !index.isCordova"><i class="fi-eye"></i>
|
||||
<span translate>View</span></button>
|
||||
<div ng-show="index.isCordova">
|
||||
<h4 translate>Export options</h4>
|
||||
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-click="copyWalletBackup()"><i class="fi-clipboard-pencil"></i>
|
||||
<span translate>Copy to clipboard</span></button>
|
||||
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-click="sendWalletBackup()"><i class="fi-mail"></i>
|
||||
<span translate>Send by email</span></button>
|
||||
</div>
|
||||
ng-click="sendWalletBackup()"><i class="fi-mail"></i>
|
||||
<span translate>Send by email</span></button>
|
||||
</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 class="row" ng-show="backupWalletPlainText">
|
||||
|
|
@ -102,6 +112,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
|
|||
|
|
@ -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