export backup without signing capabilities

This commit is contained in:
Matias Alejo Garcia 2015-07-15 22:10:59 -03:00
commit bddfa5c4d9
7 changed files with 88 additions and 9 deletions

View file

@ -8,7 +8,12 @@
<div class="content p20v" ng-controller="backupController as backup"> <div class="content p20v" ng-controller="backupController as backup">
<div class="row m20t"> <div class="row m20t">
<div class="columns" ng-show="!backup.backupWalletPlainText && !backup.error"> <div class="columns" ng-show="!backup.backupWalletPlainText">
<div class="text-warning size-14 m10v" ng-show="backup.error">
<i class="fi-alert size-12"></i>
<span translate> Failed to create backup </span>
</div>
<div class="text-warning size-14 m10v" ng-show="backup.isEncrypted"> <div class="text-warning size-14 m10v" ng-show="backup.isEncrypted">
<i class="fi-alert size-12"></i> <i class="fi-alert size-12"></i>
<span translate> The private key for this wallet is encrypted. Exporting a backup will keep the private key encrypted in the backup archive.</span> <span translate> The private key for this wallet is encrypted. Exporting a backup will keep the private key encrypted in the backup archive.</span>
@ -29,6 +34,31 @@
name="password" ng-model="backup.repeatpassword"> name="password" ng-model="backup.repeatpassword">
</div> </div>
<div class="m10t oh" ng-init="hideAdv=true">
<a class="button outline light-gray expand tiny" ng-click="hideAdv=!hideAdv">
<i class="fi-widget m3r"></i>
<span translate ng-hide="!hideAdv">Show Advanced options</span>
<span translate ng-hide="hideAdv">Hide Advanced options</span>
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
</a>
</div>
<div ng-hide="hideAdv" class="row">
<div class="large-12 columns">
<label for="no-sign" class="line-b oh">
<span translate>Do not include private key on backup</span>
<switch id="no-sign" name="noSign" ng-model="noSign" class="green right m5t m10b"></switch>
</label>
</div>
<div class="m10 size-14 text-gray" translate>
A backup without the private key will allow to see wallet balance, transaction, create spend proposals, but will not be able to approve (sign) proposals.
</div>
</div>
<button class="black round expand" ng-click="backup.downloadWalletBackup()" <button class="black round expand" ng-click="backup.downloadWalletBackup()"
ng-disabled="(!backup.password || backup.password != backup.repeatpassword)" ng-disabled="(!backup.password || backup.password != backup.repeatpassword)"
ng-style="{'background-color':index.backgroundColor}" ng-style="{'background-color':index.backgroundColor}"
@ -52,6 +82,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row m20b" ng-show="backup.backupWalletPlainText"> <div class="row m20b" ng-show="backup.backupWalletPlainText">
<div class="large-12 columns"> <div class="large-12 columns">
<h3 translate>Copy backup to a safe place</h3> <h3 translate>Copy backup to a safe place</h3>

View file

@ -102,7 +102,7 @@
<span translate>Reject</span> <span translate>Reject</span>
</button> </button>
</div> </div>
<div class="large-5 medium-5 small-6 columns text-right"> <div class="large-5 medium-5 small-6 columns text-right" ng-show="canSign">
<button class="button primary round expand" ng-click="sign(tx)" <button class="button primary round expand" ng-click="sign(tx)"
ng-style="{'background-color':color}" ng-style="{'background-color':color}"
ng-disabled="loading"> ng-disabled="loading">

View file

@ -119,6 +119,7 @@
<div class="size-12 text-gray"> <div class="size-12 text-gray">
<span translate>Multisignature wallet</span> ({{index.m}} <span translate>of</span> {{index.n}}) <span translate>Multisignature wallet</span> ({{index.m}} <span translate>of</span> {{index.n}})
<span ng-if="index.network != 'livenet'">- Testnet</span> <span ng-if="index.network != 'livenet'">- Testnet</span>
<span ng-if="!index.canSign"> - No Private key</span>
</div> </div>
</div> </div>
<div ng-show="!index.isShared"> <div ng-show="!index.isShared">
@ -127,6 +128,7 @@
</p> </p>
<div class="size-12 text-gray" ng-if="index.network != 'livenet'"> <div class="size-12 text-gray" ng-if="index.network != 'livenet'">
Testnet Testnet
<span ng-if="!index.canSign"> - No Private key</span>
</div> </div>
</div> </div>
</div> </div>

View file

@ -11,7 +11,15 @@ angular.module('copayApp.controllers').controller('backupController',
this.isEncrypted = fc.isPrivKeyEncrypted(); this.isEncrypted = fc.isPrivKeyEncrypted();
this.downloadWalletBackup = function() { this.downloadWalletBackup = function() {
backupService.walletDownload(this.password, function() { var self = this;
var opts = {
noSign: $scope.noSign,
};
backupService.walletDownload(this.password, opts, function(err) {
if (err) {
self.error = true;
return ;
}
$rootScope.$emit('Local/BackupDone'); $rootScope.$emit('Local/BackupDone');
notification.success(gettext('Backup created'), gettext('Encrypted backup file saved')); notification.success(gettext('Backup created'), gettext('Encrypted backup file saved'));
go.walletHome(); go.walletHome();
@ -19,19 +27,32 @@ angular.module('copayApp.controllers').controller('backupController',
}; };
this.getBackup = function() { this.getBackup = function() {
return backupService.walletExport(this.password); var opts = {
noSign: $scope.noSign,
};
var ew = backupService.walletExport(this.password, opts);
if (!ew) {
this.error = true;
} else {
this.error = false;
}
return ew;
}; };
this.viewWalletBackup = function() { this.viewWalletBackup = function() {
var self = this; var self = this;
$timeout(function() { $timeout(function() {
self.backupWalletPlainText = self.getBackup(); var ew = self.getBackup();
if (!ew) return;
self.backupWalletPlainText = ew;
$rootScope.$emit('Local/BackupDone'); $rootScope.$emit('Local/BackupDone');
}, 100); }, 100);
}; };
this.copyWalletBackup = function() { this.copyWalletBackup = function() {
var ew = this.getBackup(); var ew = this.getBackup();
if (!ew) return;
window.cordova.plugins.clipboard.copy(ew); window.cordova.plugins.clipboard.copy(ew);
window.plugins.toast.showShortCenter('Copied to clipboard'); window.plugins.toast.showShortCenter('Copied to clipboard');
$rootScope.$emit('Local/BackupDone'); $rootScope.$emit('Local/BackupDone');
@ -48,6 +69,11 @@ angular.module('copayApp.controllers').controller('backupController',
name = fc.alias + ' [' + name + ']'; name = fc.alias + ' [' + name + ']';
} }
var ew = this.getBackup(); var ew = this.getBackup();
if (!ew) return;
if( $scope.noSign)
name = name + '(No Private Key)';
var properties = { var properties = {
subject: 'Copay Wallet Backup: ' + name, subject: 'Copay Wallet Backup: ' + name,
body: 'Here is the encrypted backup of the wallet ' + name + ': \n\n' + ew + '\n\n To import this backup, copy all text between {...}, including the symbols {}', body: 'Here is the encrypted backup of the wallet ' + name + ': \n\n' + ew + '\n\n To import this backup, copy all text between {...}, including the symbols {}',

View file

@ -106,6 +106,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.walletName = fc.credentials.walletName; self.walletName = fc.credentials.walletName;
self.walletId = fc.credentials.walletId; self.walletId = fc.credentials.walletId;
self.isComplete = fc.isComplete(); self.isComplete = fc.isComplete();
self.canSign = fc.canSign();
self.txps = []; self.txps = [];
self.copayers = []; self.copayers = [];
self.updateColor(); self.updateColor();

View file

@ -182,6 +182,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.alternativeAmountStr = tx.alternativeAmountStr; $scope.alternativeAmountStr = tx.alternativeAmountStr;
$scope.copayers = copayers $scope.copayers = copayers
$scope.copayerId = fc.credentials.copayerId; $scope.copayerId = fc.credentials.copayerId;
$scope.canSign= fc.canSign();
$scope.loading = null; $scope.loading = null;
$scope.color = fc.backgroundColor; $scope.color = fc.backgroundColor;
refreshUntilItChanges = false; refreshUntilItChanges = false;
@ -229,6 +230,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.sign = function(txp) { $scope.sign = function(txp) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
if (!fc.canSign())
return;
if (fc.isPrivKeyEncrypted()) { if (fc.isPrivKeyEncrypted()) {
profileService.unlockFC(function(err) { profileService.unlockFC(function(err) {
if (err) { if (err) {
@ -727,6 +732,16 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return self.setSendError(err); return self.setSendError(err);
} }
if (!fc.canSign()) {
$log.info('No signing proposal: No private key')
self.setOngoingProcess();
self.resetForm();
txStatus.notify(txp, function() {
return $scope.$emit('Local/TxProposalAction');
});
return;
}
self.signAndBroadcast(txp, function(err) { self.signAndBroadcast(txp, function(err) {
self.setOngoingProcess(); self.setOngoingProcess();
profileService.lockFC(); profileService.lockFC();

View file

@ -53,13 +53,14 @@ angular.module('copayApp.services')
return cb(); return cb();
}; };
root.walletExport = function(password) { root.walletExport = function(password, opts) {
if (!password) { if (!password) {
return null; return null;
} }
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
try { try {
var b = fc.export({}); opts = opts || {};
var b = fc.export(opts);
var e = sjcl.encrypt(password, b, { var e = sjcl.encrypt(password, b, {
iter: 10000 iter: 10000
}); });
@ -70,12 +71,13 @@ angular.module('copayApp.services')
}; };
}; };
root.walletDownload = function(password, cb) { root.walletDownload = function(password, opts, cb) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
var ew = root.walletExport(password); var ew = root.walletExport(password, opts);
if (!ew) return cb('Could not create backup'); if (!ew) return cb('Could not create backup');
var walletName = (fc.alias || '') + (fc.alias ? '-' : '') + fc.credentials.walletName; var walletName = (fc.alias || '') + (fc.alias ? '-' : '') + fc.credentials.walletName;
if (opts.noSign) walletName = walletName + '-noSign'
var filename = walletName + '-Copaybackup.aes.json'; var filename = walletName + '-Copaybackup.aes.json';
_download(ew, filename, cb) _download(ew, filename, cb)
}; };