diff --git a/public/views/backup.html b/public/views/backup.html index f0f0d7a22..6db27ad45 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -6,101 +6,48 @@ -
+
-
-
- - Failed to create backup -
- -
- - The private key for this wallet is encrypted. Exporting a backup will keep the private key encrypted in the backup archive. - -
- - -
- -
- - -
- -
- - - + +
+ -
-
- -
+
+
+ + {{word}} + +
- A backup without its private key will allow the user to see the wallet balance, transactions, and create spend proposals. However, it will not be able to approve (sign) proposals. - + + Once you have wrote your backup words, it is recommended to delete them from Copay. +
+
- - - - -
-

Backup options

- - -
-
- -
-
-

Copy backup to a safe place

-
- -
-
- - Copy this text as it is to a safe place (notepad or email) -
-
+
+ +
- -
-
- * You can safely install your backup on another device and use your wallet from multiple devices at the same time. -
-
-
diff --git a/public/views/export.html b/public/views/export.html new file mode 100644 index 000000000..5a62268ac --- /dev/null +++ b/public/views/export.html @@ -0,0 +1,106 @@ +
+
+ + + +
+
+
+
+ + Failed to export +
+ +
+ + The private key for this wallet is encrypted. Exporting keep the private key encrypted in the export archive. + +
+ + +
+ +
+ + +
+ +
+ + + +
+
+ +
+ +
+ Not including the private key will allow the user to see the wallet balance, transactions, and create spend proposals. However, it will not be able to approve (sign) proposals. + +
+
+ + + + +
+

Backup options

+ + +
+
+
+ +
+
+

Copy backup to a safe place

+
+ +
+
+ + Copy this text as it is to a safe place (notepad or email) +
+
+
+ +
+
+ * You can safely install your backup on another device and use your wallet from multiple devices at the same time. +
+
+ +
+
diff --git a/public/views/includes/password.html b/public/views/includes/password.html index 64f5d0961..2cce4467b 100644 --- a/public/views/includes/password.html +++ b/public/views/includes/password.html @@ -37,7 +37,7 @@

- Password cannot be recovered. Be sure to write it down + Your wallet key will be encrypted. Password cannot be recovered. Be sure to write it down {{pass.error|translate}}

diff --git a/public/views/preferences.html b/public/views/preferences.html index fdc3f250f..d2ee6d669 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -36,8 +36,9 @@ -
  • - Encrypt Private Key + +
  • + Request Password for Spending Funds
  • @@ -49,9 +50,9 @@
  •  

    -
  • +
  • - Backup + Export
  • diff --git a/public/views/preferencesAdvanced.html b/public/views/preferencesAdvanced.html index c7fbd1d9e..c1de03794 100644 --- a/public/views/preferencesAdvanced.html +++ b/public/views/preferencesAdvanced.html @@ -16,7 +16,12 @@
  • Scan addresses for funds
  • - + +
  • + + Add access (TODO) +
  • +
  • Delete Wallet diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index ea9325a64..c270d41c6 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -1,86 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('backupController', - function($rootScope, $scope, $timeout, backupService, profileService, isMobile, isCordova, notification, go, gettext, gettextCatalog) { - this.isSafari = isMobile.Safari(); - this.isCordova = isCordova; - this.error = null; - this.success = null; - - var fc = profileService.focusedClient; - this.isEncrypted = fc.isPrivKeyEncrypted(); - - this.downloadWalletBackup = 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'); - notification.success(gettext('Backup created'), gettext('Encrypted backup file saved')); - go.walletHome(); - }); - }; - - this.getBackup = function() { - 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() { - var self = this; - $timeout(function() { - var ew = self.getBackup(); - if (!ew) return; - self.backupWalletPlainText = ew; - $rootScope.$emit('Local/BackupDone'); - }, 100); - }; - - this.copyWalletBackup = function() { - var ew = this.getBackup(); - if (!ew) return; - window.cordova.plugins.clipboard.copy(ew); - window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); - $rootScope.$emit('Local/BackupDone'); - }; - - this.sendWalletBackup = function() { +angular.module('copayApp.controllers').controller('wordsController', + function($rootScope, $scope, $timeout, profileService, go, gettext) { + this.getMnemonic = function() { var fc = profileService.focusedClient; - if (isMobile.Android() || isMobile.Windows()) { - window.ignoreMobilePause = true; - } - window.plugins.toast.showShortCenter(gettextCatalog.getString('Preparing backup...')); - var name = (fc.credentials.walletName || fc.credentials.walletId); - if (fc.alias) { - name = fc.alias + ' [' + name + ']'; - } - var ew = this.getBackup(); - if (!ew) return; + var words = fc.getMnemonic(); +console.log('[backup.js.7:words:]',words); //TODO + if (!words) return; - if( $scope.noSign) - name = name + '(No Private Key)'; - - var properties = { - 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 {}', - isHtml: false - }; - $rootScope.$emit('Local/BackupDone'); - window.plugin.email.open(properties); + return words.split(' '); }; - }); diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js new file mode 100644 index 000000000..ea9325a64 --- /dev/null +++ b/src/js/controllers/export.js @@ -0,0 +1,86 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('backupController', + function($rootScope, $scope, $timeout, backupService, profileService, isMobile, isCordova, notification, go, gettext, gettextCatalog) { + this.isSafari = isMobile.Safari(); + this.isCordova = isCordova; + this.error = null; + this.success = null; + + var fc = profileService.focusedClient; + this.isEncrypted = fc.isPrivKeyEncrypted(); + + this.downloadWalletBackup = 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'); + notification.success(gettext('Backup created'), gettext('Encrypted backup file saved')); + go.walletHome(); + }); + }; + + this.getBackup = function() { + 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() { + var self = this; + $timeout(function() { + var ew = self.getBackup(); + if (!ew) return; + self.backupWalletPlainText = ew; + $rootScope.$emit('Local/BackupDone'); + }, 100); + }; + + this.copyWalletBackup = function() { + var ew = this.getBackup(); + if (!ew) return; + window.cordova.plugins.clipboard.copy(ew); + window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); + $rootScope.$emit('Local/BackupDone'); + }; + + this.sendWalletBackup = function() { + var fc = profileService.focusedClient; + if (isMobile.Android() || isMobile.Windows()) { + window.ignoreMobilePause = true; + } + window.plugins.toast.showShortCenter(gettextCatalog.getString('Preparing backup...')); + var name = (fc.credentials.walletName || fc.credentials.walletId); + if (fc.alias) { + name = fc.alias + ' [' + name + ']'; + } + var ew = this.getBackup(); + if (!ew) return; + + if( $scope.noSign) + name = name + '(No Private Key)'; + + var properties = { + 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 {}', + isHtml: false + }; + $rootScope.$emit('Local/BackupDone'); + window.plugin.email.open(properties); + }; + + }); diff --git a/src/js/routes.js b/src/js/routes.js index 18f4206f8..e309bec55 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -453,6 +453,17 @@ angular }, } }) + .state('export', { + url: '/export', + templateUrl: 'views/export.html', + walletShouldBeComplete: true, + needProfile: true, + views: { + 'main': { + templateUrl: 'views/export.html' + }, + } + }) .state('backup', { url: '/backup', templateUrl: 'views/backup.html', diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index c0bfe7ec7..d3dcf88ba 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -172,6 +172,17 @@ angular.module('copayApp.services') } var walletClient = bwcService.getClient(); + // TODO LANG... + // TODO... + walletClient.seedFromRandomWithMnemonic('livenet'); +console.log('[profileService.js.200:walletClient:]',walletClient); //TODO + +console.log('[profileService.js.180]'); //TODO +console.log('[profileService.js.180]'); //TODO +console.log('[profileService.js.180]'); //TODO +console.log('[profileService.js.180]'); //TODO +console.log('[profileService.js.180]'); //TODO + walletClient.createWallet('Personal Wallet', 'me', 1, 1, { network: 'livenet' }, function(err) { @@ -200,6 +211,11 @@ angular.module('copayApp.services') return cb(gettext('Could not create using the specified extended public key')); } } + // TODO LANG... + // TODO... + walletClient.seedFromRandomWithMnemonic(opts.networkName); +console.log('[profileService.js.200:walletClient:]',walletClient); //TODO + walletClient.createWallet(opts.name, opts.myName || 'me', opts.m, opts.n, { network: opts.networkName }, function(err, secret) {