aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/account-import-strategies/index.js
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-06-15 01:11:35 +0800
committerGitHub <noreply@github.com>2018-06-15 01:11:35 +0800
commitd9ef72cb7ef78a1c2bf7ce119352425d72a10dc0 (patch)
tree6c14bb94e21996bdf688cc08011c8955322697ad /app/scripts/account-import-strategies/index.js
parent11bfdf444dca3917479cff82f807cc0d4c217191 (diff)
parentd814bee578bfe931766804612ed57a545e4b21a8 (diff)
downloadtangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.tar
tangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.tar.gz
tangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.tar.bz2
tangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.tar.lz
tangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.tar.xz
tangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.tar.zst
tangerine-wallet-browser-d9ef72cb7ef78a1c2bf7ce119352425d72a10dc0.zip
Merge branch 'develop' into save-brave
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) => {