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
1 changed files with 3 additions and 2 deletions

View File

@ -20,13 +20,14 @@ const accountImporter = {
throw new Error('Cannot import an empty key.')
}
const stripped = ethUtil.stripHexPrefix(privateKey)
const buffer = ethUtil.toBuffer(stripped)
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) => {