1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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.
This commit is contained in:
Dan Finlay 2018-06-05 13:44:03 -07:00
parent 3b6e96bac9
commit d61c979de6

View File

@ -16,6 +16,9 @@ const accountImporter = {
strategies: { strategies: {
'Private Key': (privateKey) => { 'Private Key': (privateKey) => {
if (!privateKey) {
throw new Error('Cannot import an empty key.')
}
const stripped = ethUtil.stripHexPrefix(privateKey) const stripped = ethUtil.stripHexPrefix(privateKey)
return stripped return stripped
}, },