commit
a735a3d0eb
6 changed files with 146 additions and 174 deletions
|
|
@ -1,20 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('exportController',
|
||||
function($rootScope, $scope, $timeout, $log, $ionicHistory, lodash, backupService, walletService, storageService, profileService, platformInfo, gettext, gettextCatalog, $state, $stateParams, popupService) {
|
||||
var prevState;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
|
||||
function($scope, $timeout, $log, $ionicHistory, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.isEncrypted = wallet.isPrivKeyEncrypted();
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.supported = true;
|
||||
$scope.exportQR = false;
|
||||
$scope.noSignEnabled = false;
|
||||
$scope.formData = {};
|
||||
$scope.isEncrypted = wallet.isPrivKeyEncrypted();
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.formData.noSignEnabled = false;
|
||||
$scope.showAdvanced = false;
|
||||
$scope.wallet = wallet;
|
||||
$scope.canSign = wallet.canSign();
|
||||
|
|
@ -22,13 +17,15 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
walletService.getEncodedWalletInfo(wallet, function(err, code) {
|
||||
if (err || !code) {
|
||||
$log.warn(err);
|
||||
return $state.go('wallet.preferencesAdvanced')
|
||||
return $ionicHistory.goBack();
|
||||
}
|
||||
|
||||
if (!code)
|
||||
$scope.supported = false;
|
||||
else
|
||||
$scope.exportWalletInfo = code;
|
||||
$scope.formData.supported = false;
|
||||
else {
|
||||
$scope.formData.supported = true;
|
||||
$scope.formData.exportWalletInfo = code;
|
||||
}
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
|
|
@ -38,14 +35,25 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
|
||||
/*
|
||||
EXPORT WITHOUT PRIVATE KEY - PENDING
|
||||
*/
|
||||
|
||||
$scope.noSignEnabledChange = function() {
|
||||
$scope.exportWalletInfo = encodeWalletInfo();
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
if (!$scope.formData.supported) return;
|
||||
|
||||
walletService.getEncodedWalletInfo(wallet, function(err, code) {
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
$scope.formData.supported = false;
|
||||
$scope.formData.exportWalletInfo = null;
|
||||
} else {
|
||||
$scope.formData.supported = true;
|
||||
$scope.formData.exportWalletInfo = code;
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
};
|
||||
*/
|
||||
|
||||
$scope.downloadWalletBackup = function() {
|
||||
$scope.getAddressbook(function(err, localAddressBook) {
|
||||
|
|
@ -54,11 +62,11 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
return;
|
||||
}
|
||||
var opts = {
|
||||
noSign: $scope.noSignEnabled,
|
||||
noSign: $scope.formData.noSignEnabled,
|
||||
addressBook: localAddressBook
|
||||
};
|
||||
|
||||
backupService.walletDownload($scope.password, opts, function(err) {
|
||||
backupService.walletDownload($scope.formData.password, opts, function(err) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
|
||||
return;
|
||||
|
|
@ -91,11 +99,11 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
return cb(null);
|
||||
}
|
||||
var opts = {
|
||||
noSign: $scope.noSignEnabled,
|
||||
noSign: $scope.formData.noSignEnabled,
|
||||
addressBook: localAddressBook
|
||||
};
|
||||
|
||||
var ew = backupService.walletExport($scope.password, opts);
|
||||
var ew = backupService.walletExport($scope.formData.password, opts);
|
||||
if (!ew) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
|
||||
}
|
||||
|
|
@ -132,7 +140,7 @@ angular.module('copayApp.controllers').controller('exportController',
|
|||
var ew = backup;
|
||||
if (!ew) return;
|
||||
|
||||
if ($scope.noSignEnabled)
|
||||
if ($scope.formData.noSignEnabled)
|
||||
name = name + '(No Private Key)';
|
||||
|
||||
var subject = 'Copay Wallet Backup: ' + name;
|
||||
|
|
|
|||
|
|
@ -434,7 +434,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.preferences.export', {
|
||||
abstract: true,
|
||||
url: '/export',
|
||||
views: {
|
||||
'preferences': {
|
||||
|
|
@ -442,24 +441,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.export.file', {
|
||||
url: '/tab-export-file',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'tab-export-file': {
|
||||
templateUrl: 'views/tab-export-file.html',
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.export.qrCode', {
|
||||
url: '/tab-export-qrCode',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'tab-export-qrCode': {
|
||||
templateUrl: 'views/tab-export-qrCode.html',
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.preferencesBwsUrl', {
|
||||
url: '/preferencesBwsUrl',
|
||||
views: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue