From 691ac5d288963f376e34c1711e23bbd58432396f Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 13 Jun 2018 21:06:33 -0700 Subject: [PATCH] account-import-strategies - ensure privateKey is prefixed before converting to buffer --- app/scripts/account-import-strategies/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scripts/account-import-strategies/index.js b/app/scripts/account-import-strategies/index.js index 5972cb345..16ae224ea 100644 --- a/app/scripts/account-import-strategies/index.js +++ b/app/scripts/account-import-strategies/index.js @@ -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) => {