Browse Source

FIX: Current storage will be the selected one for decrypt

settingsui
Marcos Rodriguez 5 years ago
parent
commit
38048b2068
  1. 38
      class/app-storage.js
  2. 2
      screen/settings/encryptStorage.js

38
class/app-storage.js

@ -143,32 +143,16 @@ export class AppStorage {
}
async decryptStorage(password) {
try {
let storage = await this.getItem('data');
if (password) {
let parsedStorage = JSON.parse(storage);
let mainStorage = parsedStorage[0];
mainStorage = JSON.stringify([mainStorage]);
const decrypted = this.decryptData(mainStorage, password);
if (!decrypted) {
throw new Error('Wrong password for main storage.');
}
const decryptedParsed = JSON.parse(decrypted);
if (decrypted.wallets !== null) {
this.wallets = decryptedParsed.wallets;
this.tx_metadata = decryptedParsed.tx_metadata;
this.cachedPassword = undefined;
await this.setItem(AppStorage.FLAG_ENCRYPTED, '', { accessible: ACCESSIBLE.WHEN_UNLOCKED });
await this.setItem('deleteWalletAfterUninstall', '1', { accessible: ACCESSIBLE.WHEN_UNLOCKED });
await this.saveToDisk();
this.wallets = [];
this.tx_metadata = [];
return this.loadFromDisk();
}
}
} catch (e) {
console.log(e);
throw new Error(e);
if (password === this.cachedPassword) {
this.cachedPassword = undefined;
await this.setItem(AppStorage.FLAG_ENCRYPTED, '');
await this.setItem('deleteWalletAfterUninstall', '1');
await this.saveToDisk();
this.wallets = [];
this.tx_metadata = [];
return this.loadFromDisk();
} else {
throw new Error('Wrong password. Please, try again.');
}
}
@ -514,4 +498,4 @@ export class AppStorage {
async sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
}

2
screen/settings/encryptStorage.js

@ -102,7 +102,7 @@ export default class EncryptStorage extends Component {
} else {
Alert.alert(
'Decrypt Storage',
'Are you sure you want to decrypt your storage? This will allow your wallets to be accessed without a password, and remove your plausible deniability wallets.',
'Are you sure you want to decrypt your storage? This will allow your wallets to be accessed without a password.',
[
{
text: loc.send.details.cancel,

Loading…
Cancel
Save