2018-03-31 02:03:58 +02:00
|
|
|
/* global alert */
|
2018-01-30 23:42:38 +01:00
|
|
|
/**
|
|
|
|
* @exports {AppStorage}
|
|
|
|
*/
|
2018-03-17 21:39:21 +01:00
|
|
|
import { AppStorage } from './class';
|
2018-03-31 02:03:58 +02:00
|
|
|
let prompt = require('./prompt');
|
2018-03-17 21:39:21 +01:00
|
|
|
let EV = require('./events');
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2018-03-31 02:03:58 +02:00
|
|
|
/** @type {AppStorage} */
|
2018-03-17 21:39:21 +01:00
|
|
|
let BlueApp = new AppStorage();
|
2018-03-31 02:03:58 +02:00
|
|
|
|
2018-03-17 21:39:21 +01:00
|
|
|
(async () => {
|
2018-03-31 02:03:58 +02:00
|
|
|
let password = false;
|
|
|
|
if (await BlueApp.storageIsEncrypted()) {
|
|
|
|
password = await prompt(
|
|
|
|
'Enter password',
|
|
|
|
'Your storage is encrypted. Password is required to decrypt it',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
let success = await BlueApp.loadFromDisk(password);
|
|
|
|
if (success) {
|
|
|
|
console.log('loaded from disk');
|
|
|
|
EV(EV.enum.WALLETS_COUNT_CHANGED);
|
|
|
|
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!success && password) {
|
|
|
|
// we had password and yet could not load/decrypt
|
|
|
|
alert('Could not decrypt. Bad password.');
|
|
|
|
}
|
2018-03-17 21:39:21 +01:00
|
|
|
})();
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2018-03-17 21:39:21 +01:00
|
|
|
module.exports = BlueApp;
|