aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/account-import-strategies
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-02 05:41:34 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-02 05:41:34 +0800
commit1494cc5e6c5943095c89e3b243b0a6152876e72c (patch)
treee34e74e79e8d41ce5903cc8d6eedf5caa19bc354 /app/scripts/account-import-strategies
parent6e563acd93cbaf20fb233a267104fc6af3384287 (diff)
parentb2e64f24ecbc9e309869e678254cf755ffe11b40 (diff)
downloadtangerine-wallet-browser-1494cc5e6c5943095c89e3b243b0a6152876e72c.tar.gz
tangerine-wallet-browser-1494cc5e6c5943095c89e3b243b0a6152876e72c.tar.zst
tangerine-wallet-browser-1494cc5e6c5943095c89e3b243b0a6152876e72c.zip
fix merge conflicts
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) => {