From d61c979de68934f9d2315261fdaa35fa601d7969 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 5 Jun 2018 13:44:03 -0700 Subject: [PATCH] Add validation for importing empty private key Previously importing an empty string would result in a new empty Keyring object to be constructed, with no notification to the user. Now we render a clear error explaining the mistake. --- app/scripts/account-import-strategies/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/scripts/account-import-strategies/index.js b/app/scripts/account-import-strategies/index.js index 96e2b5912..9f2703571 100644 --- a/app/scripts/account-import-strategies/index.js +++ b/app/scripts/account-import-strategies/index.js @@ -16,6 +16,9 @@ const accountImporter = { strategies: { 'Private Key': (privateKey) => { + if (!privateKey) { + throw new Error('Cannot import an empty key.') + } const stripped = ethUtil.stripHexPrefix(privateKey) return stripped },