diff options
author | Dan <danjm.com@gmail.com> | 2018-06-20 08:09:52 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2018-06-20 08:09:52 +0800 |
commit | 06307ef8aeb707faa6aaad6eab9b31e8c9eac173 (patch) | |
tree | 402355ca71c5e973c4017f2d842421f04caa1db2 /app/scripts/account-import-strategies/index.js | |
parent | bb855707efbcb754f5e4ee4e124f69308bca037d (diff) | |
parent | 40fad619088bd955d5505cc839a7521ac43235f9 (diff) | |
download | tangerine-wallet-browser-06307ef8aeb707faa6aaad6eab9b31e8c9eac173.tar.gz tangerine-wallet-browser-06307ef8aeb707faa6aaad6eab9b31e8c9eac173.tar.zst tangerine-wallet-browser-06307ef8aeb707faa6aaad6eab9b31e8c9eac173.zip |
Merge branch 'develop' into i4409-i4410-ens-input-enhancements
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) => { |