mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-16 04:57:08 +00:00
1. Attempt an empty password every time a keystore is uploaded. 2. Delegate scrypt decryption (ie ethereumjs-wallet.fromV3) to its own web worker and interface with it through an async typescript function that gets handled in the wallet saga. This keeps the UI unblocked when scrypt takes a long time to decrypt. 3. Add logic to show a spinner x number of milliseconds after file upload so the user will understand when a wallet is being decrypted.
19 lines
527 B
TypeScript
19 lines
527 B
TypeScript
import { fromV3, IFullWallet } from 'ethereumjs-wallet';
|
|
|
|
const scryptWorker: Worker = self as any;
|
|
interface DecryptionParameters {
|
|
keystore: string;
|
|
password: string;
|
|
nonStrict: boolean;
|
|
}
|
|
|
|
scryptWorker.onmessage = (event: MessageEvent) => {
|
|
const info: DecryptionParameters = event.data;
|
|
try {
|
|
const rawKeystore: IFullWallet = fromV3(info.keystore, info.password, info.nonStrict);
|
|
scryptWorker.postMessage(rawKeystore.getPrivateKeyString());
|
|
} catch (e) {
|
|
scryptWorker.postMessage(e.message);
|
|
}
|
|
};
|