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

account-import-strategies - ensure privateKey is prefixed before converting to buffer

This commit is contained in:
kumavis 2018-06-13 21:06:33 -07:00
parent 7a001447a8
commit 691ac5d288

View File

@ -20,13 +20,14 @@ const accountImporter = {
throw new Error('Cannot import an empty key.') throw new Error('Cannot import an empty key.')
} }
const stripped = ethUtil.stripHexPrefix(privateKey) const prefixed = ethUtil.addHexPrefix(privateKey)
const buffer = ethUtil.toBuffer(stripped) const buffer = ethUtil.toBuffer(prefixed)
if (!ethUtil.isValidPrivate(buffer)) { if (!ethUtil.isValidPrivate(buffer)) {
throw new Error('Cannot import invalid private key.') throw new Error('Cannot import invalid private key.')
} }
const stripped = ethUtil.stripHexPrefix(prefixed)
return stripped return stripped
}, },
'JSON File': (input, password) => { 'JSON File': (input, password) => {