2014-03-26 05:18:42 -07:00
|
|
|
'use strict';
|
|
|
|
|
2014-06-03 13:42:36 -07:00
|
|
|
angular.module('copayApp.controllers').controller('BackupController',
|
2014-08-20 17:52:31 -07:00
|
|
|
function($scope, $rootScope, $location, backupService, walletFactory, controllerUtils, notification) {
|
2014-08-20 17:29:07 -07:00
|
|
|
var s = ($location.search()).advanced;
|
2014-08-20 11:06:37 -07:00
|
|
|
if (s) {
|
|
|
|
var w = $rootScope.wallet;
|
2014-08-20 17:52:31 -07:00
|
|
|
$scope.advanced = 1;
|
|
|
|
$scope.priv = w.privateKey.toObj().extendedPrivateKeyString;
|
2014-08-20 11:06:37 -07:00
|
|
|
}
|
|
|
|
|
2014-08-20 17:52:31 -07:00
|
|
|
|
2014-07-16 15:00:34 -07:00
|
|
|
$scope.downloadBackup = function() {
|
2014-07-16 13:59:28 -07:00
|
|
|
var w = $rootScope.wallet;
|
|
|
|
backupService.download(w);
|
|
|
|
}
|
|
|
|
|
2014-06-16 11:51:19 -07:00
|
|
|
$scope.deleteWallet = function() {
|
2014-06-16 13:37:33 -07:00
|
|
|
var w = $rootScope.wallet;
|
2014-06-16 11:51:19 -07:00
|
|
|
w.disconnect();
|
2014-06-16 13:37:33 -07:00
|
|
|
walletFactory.delete(w.id, function() {
|
2014-06-16 11:51:19 -07:00
|
|
|
controllerUtils.logout();
|
|
|
|
});
|
|
|
|
};
|
2014-08-20 17:52:31 -07:00
|
|
|
|
|
|
|
$scope.updateIndexes = function() {
|
|
|
|
var w = $rootScope.wallet;
|
|
|
|
|
|
|
|
notification.info('Scaning for transactions','Using derived addresses from your wallet');
|
|
|
|
w.updateIndexes(function(err) {
|
|
|
|
notification.info('Scan Ended', 'Updating balance');
|
|
|
|
if (err) {
|
|
|
|
notification.error('Error', 'Error updating indexes: ' + err);
|
|
|
|
}
|
|
|
|
controllerUtils.updateAddressList();
|
|
|
|
controllerUtils.updateBalance(function(){
|
|
|
|
notification.info('Finished', 'The balance is updated using the derived addresses');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2014-06-16 11:51:19 -07:00
|
|
|
});
|