aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/account-import-strategies/index.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-20 08:09:52 +0800
committerDan <danjm.com@gmail.com>2018-06-20 08:09:52 +0800
commit06307ef8aeb707faa6aaad6eab9b31e8c9eac173 (patch)
tree402355ca71c5e973c4017f2d842421f04caa1db2 /app/scripts/account-import-strategies/index.js
parentbb855707efbcb754f5e4ee4e124f69308bca037d (diff)
parent40fad619088bd955d5505cc839a7521ac43235f9 (diff)
downloadtangerine-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.js13
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) => {