mirror of https://github.com/BTCPrivate/copay.git
added message for backup to file for when instide copay shell
This commit is contained in:
parent
2818ff6d60
commit
ceafc3bb4f
|
@ -15,6 +15,15 @@ angular.module('copay.backup').controller('BackupController',
|
|||
var filename = walletName + '-' + timestamp + '.json.aes';
|
||||
var wallet = _getEncryptedWallet();
|
||||
var blob = new Blob([wallet], {type: 'text/plain;charset=utf-8'});
|
||||
// show a native save dialog if we are in the shell
|
||||
// and pass the wallet to the shell to convert to node Buffer
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:download', {
|
||||
name: walletName,
|
||||
wallet: wallet
|
||||
});
|
||||
}
|
||||
// otherwise lean on the browser implementation
|
||||
saveAs(blob, filename);
|
||||
};
|
||||
|
||||
|
|
20
js/shell.js
20
js/shell.js
|
@ -17,6 +17,9 @@
|
|||
if (window.process && process.type === 'renderer') {
|
||||
window.cshell = initCopayShellBindings();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
function controller(name) {
|
||||
return angular.element(
|
||||
|
@ -35,46 +38,51 @@
|
|||
var ipc = require('ipc');
|
||||
|
||||
ipc.on('address:create', function(data) {
|
||||
location.href = '#/addresses';
|
||||
var ctrl = controller('AddressesController');
|
||||
if (!ctrl) return needsWalletLogin(ipc);
|
||||
location.href = '#/addresses';
|
||||
ctrl.newAddr();
|
||||
});
|
||||
|
||||
ipc.on('transactions:send', function(data) {
|
||||
location.href = '#/send';
|
||||
var ctrl = controller('SendController');
|
||||
if (!ctrl) return needsWalletLogin(ipc);
|
||||
location.href = '#/send';
|
||||
});
|
||||
|
||||
ipc.on('transactions:all', function(data) {
|
||||
location.href = '#/transactions';
|
||||
var ctrl = controller('TransactionsController');
|
||||
if (!ctrl) return needsWalletLogin(ipc);
|
||||
location.href = '#/transactions';
|
||||
ctrl.show();
|
||||
});
|
||||
|
||||
ipc.on('transactions:pending', function(data) {
|
||||
location.href = '#/transactions';
|
||||
var ctrl = controller('TransactionsController');
|
||||
if (!ctrl) return needsWalletLogin(ipc);
|
||||
location.href = '#/transactions';
|
||||
ctrl.show(true);
|
||||
});
|
||||
|
||||
ipc.on('backup:download', function(data) {
|
||||
location.href = '#/backup';
|
||||
var ctrl = controller('BackupController');
|
||||
if (!ctrl) return needsWalletLogin(ipc);
|
||||
location.href = '#/backup';
|
||||
ctrl.download();
|
||||
});
|
||||
|
||||
ipc.on('backup:email', function(data) {
|
||||
location.href = '#/backup';
|
||||
var ctrl = controller('BackupController');
|
||||
if (!ctrl) return needsWalletLogin(ipc);
|
||||
location.href = '#/backup';
|
||||
ctrl.email();
|
||||
});
|
||||
|
||||
// let the shell know when an error occurs
|
||||
window.onerror = function(err) {
|
||||
ipc.send('error', err);
|
||||
};
|
||||
|
||||
return ipc;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue