mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-09 10:41:56 +00:00
af2e0b69e1
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.
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { fromPrivateKey, fromEthSale } from 'ethereumjs-wallet';
|
|
import { fromEtherWallet } from 'ethereumjs-wallet/thirdparty';
|
|
import { signWrapper } from './helpers';
|
|
import { decryptPrivKey } from 'libs/decrypt';
|
|
import { fromV3 } from 'libs/web-workers/scrypt-wrapper';
|
|
import Web3Wallet from './web3';
|
|
import AddressOnlyWallet from './address';
|
|
|
|
const EncryptedPrivateKeyWallet = (encryptedPrivateKey: string, password: string) =>
|
|
signWrapper(fromPrivateKey(decryptPrivKey(encryptedPrivateKey, password)));
|
|
|
|
const PresaleWallet = (keystore: string, password: string) =>
|
|
signWrapper(fromEthSale(keystore, password));
|
|
|
|
const MewV1Wallet = (keystore: string, password: string) =>
|
|
signWrapper(fromEtherWallet(keystore, password));
|
|
|
|
const PrivKeyWallet = (privkey: Buffer) => signWrapper(fromPrivateKey(privkey));
|
|
|
|
const UtcWallet = (keystore: string, password: string) => fromV3(keystore, password, true);
|
|
|
|
export {
|
|
EncryptedPrivateKeyWallet,
|
|
PresaleWallet,
|
|
MewV1Wallet,
|
|
PrivKeyWallet,
|
|
UtcWallet,
|
|
Web3Wallet,
|
|
AddressOnlyWallet
|
|
};
|