diff options
author | kumavis <aaron@kumavis.me> | 2018-07-03 04:54:05 +0800 |
---|---|---|
committer | kumavis <aaron@kumavis.me> | 2018-07-03 04:54:05 +0800 |
commit | a89902c1701f2dcc41effc06d2315e515946b2ca (patch) | |
tree | 922408cf99bcca97c956d5860ac80c2c0c472ecc /app/scripts/account-import-strategies/index.js | |
parent | 055346843bc90a5168151ba2adc9deacedf8afd4 (diff) | |
parent | 4c86f25f5bc4fa18847ca1b77e005afc3f37eddc (diff) | |
download | tangerine-wallet-browser-a89902c1701f2dcc41effc06d2315e515946b2ca.tar.gz tangerine-wallet-browser-a89902c1701f2dcc41effc06d2315e515946b2ca.tar.zst tangerine-wallet-browser-a89902c1701f2dcc41effc06d2315e515946b2ca.zip |
Merge branch 'develop' of github.com:MetaMask/metamask-extension into network-remove-provider-engine
Diffstat (limited to 'app/scripts/account-import-strategies/index.js')
-rw-r--r-- | app/scripts/account-import-strategies/index.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/scripts/account-import-strategies/index.js b/app/scripts/account-import-strategies/index.js index 96e2b5912..16ae224ea 100644 --- a/app/scripts/account-import-strategies/index.js +++ b/app/scripts/account-import-strategies/index.js @@ -16,7 +16,18 @@ const accountImporter = { strategies: { 'Private Key': (privateKey) => { - const stripped = ethUtil.stripHexPrefix(privateKey) + if (!privateKey) { + throw new Error('Cannot import an empty key.') + } + + const prefixed = ethUtil.addHexPrefix(privateKey) + const buffer = ethUtil.toBuffer(prefixed) + + if (!ethUtil.isValidPrivate(buffer)) { + throw new Error('Cannot import invalid private key.') + } + + const stripped = ethUtil.stripHexPrefix(prefixed) return stripped }, 'JSON File': (input, password) => { |