aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-06-14 13:01:00 +0800
committerGitHub <noreply@github.com>2018-06-14 13:01:00 +0800
commit1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5 (patch)
treeda584d964cf84470250f242923967afa7b6a4822 /app/scripts
parent66c77dc2bd95f40e2d6113e3b932e25c6dc8030c (diff)
parente9cb6508324c166a2d6efe53cf82c39abd4520b4 (diff)
downloadtangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.tar
tangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.tar.gz
tangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.tar.bz2
tangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.tar.lz
tangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.tar.xz
tangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.tar.zst
tangerine-wallet-browser-1f83a110b959fcf9d8fa7cedb852f6c665bd0fc5.zip
Merge pull request #4513 from MetaMask/ValidateEmptyKey
Validate empty key
Diffstat (limited to 'app/scripts')
-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) => {