diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-01-19 08:45:39 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-01-19 08:45:39 +0800 |
commit | 5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c (patch) | |
tree | 4e6077ee705d894bbe33945c57ede27403aeb1e0 /app/scripts | |
parent | 9126652f2e8b5b612f894bbb6c46fb1ef7861d06 (diff) | |
download | tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.tar tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.tar.gz tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.tar.bz2 tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.tar.lz tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.tar.xz tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.tar.zst tangerine-wallet-browser-5d8a3dd99b0cebad48e2fdcc4c407d7d89d4717c.zip |
Add ability to import v3 JSON wallets
There is now a menu item labeled "JSON File" for importing, and it can digest either:
- v1 MyEtherWallet JSON files
- v3 Account files (used by Geth, Mist, and MyEtherWallet).
Fixes #715
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/account-import-strategies/index.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/scripts/account-import-strategies/index.js b/app/scripts/account-import-strategies/index.js index 8f4456cdf..d5124eb7f 100644 --- a/app/scripts/account-import-strategies/index.js +++ b/app/scripts/account-import-strategies/index.js @@ -7,8 +7,7 @@ const accountImporter = { importAccount(strategy, args) { try { const importer = this.strategies[strategy] - const wallet = importer.apply(null, args) - const privateKeyHex = walletToPrivateKey(wallet) + const privateKeyHex = importer.apply(null, args) return Promise.resolve(privateKeyHex) } catch (e) { return Promise.reject(e) @@ -18,11 +17,20 @@ const accountImporter = { strategies: { 'Private Key': (privateKey) => { const stripped = ethUtil.stripHexPrefix(privateKey) - const buffer = new Buffer(stripped, 'hex') - return Wallet.fromPrivateKey(buffer) + return stripped }, 'JSON File': (input, password) => { - const wallet = importers.fromEtherWallet(input, password) + let wallet + try { + wallet = importers.fromEtherWallet(input, password) + } catch (e) { + console.log('Attempt to import as EtherWallet format failed, trying V3...') + } + + if (!wallet) { + wallet = Wallet.fromV3(input, password, true) + } + return walletToPrivateKey(wallet) }, }, |