From c5f80c72b95831b436f20546b75dece20dd63a73 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 14 May 2018 16:38:15 -0400 Subject: [PATCH] add 0x if private key doesn't have it --- lib/core/provider.js | 6 ++++++ lib/i18n/locales/en.json | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/core/provider.js b/lib/core/provider.js index 444290407..824d812b8 100644 --- a/lib/core/provider.js +++ b/lib/core/provider.js @@ -60,12 +60,18 @@ class Provider { getAccount(accountConfig) { if (accountConfig.privateKey) { + if (!accountConfig.privateKey.startsWith('0x')) { + accountConfig.privateKey = '0x' + accountConfig.privateKey; + } return this.web3.eth.accounts.privateKeyToAccount(accountConfig.privateKey); } if (accountConfig.privateKeyFile) { let fileContent = fs.readFileSync(fs.dappPath(accountConfig.privateKeyFile)).toString(); fileContent = fileContent.trim().split(/[,;]/); return fileContent.map(key => { + if (!key.startsWith('0x')) { + key = '0x' + key; + } return this.web3.eth.accounts.privateKeyToAccount(key); }); } diff --git a/lib/i18n/locales/en.json b/lib/i18n/locales/en.json index 39808b2a3..01ed44df0 100644 --- a/lib/i18n/locales/en.json +++ b/lib/i18n/locales/en.json @@ -92,5 +92,7 @@ "Development blockchain has changed to use the --dev option.": "Development blockchain has changed to use the --dev option.", "You can reset your workspace to fix the problem with": "You can reset your workspace to fix the problem with", "Otherwise, you can change your data directory in blockchain.json (datadir)": "Otherwise, you can change your data directory in blockchain.json (datadir)", - "tip: you can resize the terminal or disable the dashboard with": "tip: you can resize the terminal or disable the dashboard with" + "tip: you can resize the terminal or disable the dashboard with": "tip: you can resize the terminal or disable the dashboard with", + "help": "help", + "quit": "quit" } \ No newline at end of file