According to the example in the documentation, function web3.eth.accounts.privateKeyToAccount expects private key to be passed to hexadecimal string prefixed with "0x". If private key is passed without "0x" prefix, the function silently returns incorrect result.
Function web3.eth.accounts.privateKeyToAccount throws on incorrect private key format, and always returns correct result on correctly formatted private keys. Whether hexadecimal private key without "0x" prefix is correct or not is discussible.
On hexadecimal private key without "0x" prefix function web3.eth.accounts.privateKeyToAccount silently returns incorrect result.
Call function web3.eth.accounts.privateKeyToAccount with parameters 0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709 and 348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709 and compare the results.
same for web3.js version 1.2.1
It returns a faulty result WITHOUT the 0x prefix
@3sGgpQ8H @DalderupMaurice I had the same issue, it looks like the fix has already landed in the [email protected] pre-release (fixed in https://github.com/ethereum/web3.js/pull/2929) so this should be fixed in the next release.
@3sGgpQ8H @DalderupMaurice I had the same issue, it looks like the fix has already landed in the
[email protected]pre-release (fixed in #2929) so this should be fixed in the next release.
Yes! I saw it was mentioned in the release notes afterward.
It should be an easy backport until the v2 goes live though
Most helpful comment
Yes! I saw it was mentioned in the release notes afterward.
It should be an easy backport until the v2 goes live though