aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/account-import-strategies
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-04 02:21:17 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-04 02:21:17 +0800
commit595447ccac0c6d178d63850d45f0ad5456964e4f (patch)
tree61b83e1ba63615351da8e4c2dc7b446353411c9d /app/scripts/account-import-strategies
parent11736e6318182ab5b43430410a46059e5f46ad52 (diff)
parent2e9bd7e9d101287b4466475561df9131f0ef56a6 (diff)
downloadtangerine-wallet-browser-595447ccac0c6d178d63850d45f0ad5456964e4f.tar.gz
tangerine-wallet-browser-595447ccac0c6d178d63850d45f0ad5456964e4f.tar.zst
tangerine-wallet-browser-595447ccac0c6d178d63850d45f0ad5456964e4f.zip
Merge remote-tracking branch 'upstream/develop' into HEAD
Diffstat (limited to 'app/scripts/account-import-strategies')
-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) => {