Browse Source

FIX: Resolved crash when decrypting and going back to the wallets list

settingsui
Marcos Rodriguez 5 years ago
parent
commit
29901ab399
  1. 9
      class/app-storage.js
  2. 2
      loc/en.js
  3. 7
      screen/settings/encryptStorage.js

9
class/app-storage.js

@ -149,7 +149,7 @@ export class AppStorage {
let parsedStorage = JSON.parse(storage);
let mainStorage = parsedStorage[0];
mainStorage = JSON.stringify([mainStorage]);
let decrypted = this.decryptData(mainStorage, password);
const decrypted = this.decryptData(mainStorage, password);
if (!decrypted) {
throw new Error('Wrong password for main storage.');
}
@ -160,7 +160,10 @@ export class AppStorage {
this.cachedPassword = undefined;
await this.setItem(AppStorage.FLAG_ENCRYPTED, '', { accessible: ACCESSIBLE.WHEN_UNLOCKED });
await this.setItem('deleteWalletAfterUninstall', '1', { accessible: ACCESSIBLE.WHEN_UNLOCKED });
return this.saveToDisk();
await this.saveToDisk();
this.wallets = [];
this.tx_metadata = [];
return this.loadFromDisk();
}
}
} catch (e) {
@ -343,8 +346,8 @@ export class AppStorage {
let walletsToSave = [];
for (let key of this.wallets) {
if (typeof key === 'boolean') continue;
if (key.prepareForSerialization) key.prepareForSerialization();
if (typeof key === 'string') key = JSON.parse(key);
if (key.prepareForSerialization) key.prepareForSerialization();
walletsToSave.push(JSON.stringify({ ...key, type: key.type }));
}

2
loc/en.js

@ -2,7 +2,7 @@ module.exports = {
_: {
storage_is_encrypted: 'Your storage is encrypted. Password is required to decrypt it',
enter_password: 'Enter password',
bad_password: 'Bad password, try again',
bad_password: 'Wrong password, please try again.',
never: 'never',
continue: 'Continue',
ok: 'OK',

7
screen/settings/encryptStorage.js

@ -41,11 +41,7 @@ export default class EncryptStorage extends Component {
});
try {
await BlueApp.decryptStorage(password);
this.setState({
isLoading: false,
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
deleteWalletAfterUninstall: await BlueApp.isDeleteWalletAfterUninstallEnabled(),
});
this.props.navigation.popToTop();
} catch (e) {
if (password) {
alert(loc._.bad_password);
@ -154,6 +150,7 @@ export default class EncryptStorage extends Component {
EncryptStorage.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
popToTop: PropTypes.func,
goBack: PropTypes.func,
}),
};

Loading…
Cancel
Save