-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new Wallet(privateKey) throws "invalid hexlify value" when privateKey is not 0x prefixed #1166
Comments
Heya! Ethers 100% requires all hex strings to be This was also required in v4 (I just installed v4 to verify). So, it is not a breaking change since v4.
In fact, if I do the same with ethers@2.0.0 The same thing happens. I believe the requirement was present since 0.0.1, but my memory gets a little foggy that far back, cut I seem to recall people at the time complaining, but I believe in explicitly declaring intentions, and since strings are used for myriad things in JavaScript, it is the least worst way to indicate the string's intention as an octet-string. |
I'm very certain this is not an issue in Ethers V4, as I personally have experienced, and the author of the linked post also experienced that, it was perfectly ok to use non-0x-prefixed private key in V4 to construct a wallet object. The issue only showed up as we upgraded form v4 to v5. I was using 4.0.43. |
Perhaps there is somewhere else the hex string is being generated that used to You can install v4 to try it out, maybe there is some other aspect that has changed I am not thinking of, but you can install v4 direct via a specific version or use the tag |
(I just installed 4.0.43 and verified it throws the same error) |
using a valid random private key and ethers@4.0.43, a wallet object was returned |
What is the result of That seems very odd, because I know I have code in there to check the regex of the string coming in... :) |
so as in the screenshot, it is Ethers 4.0.43. We had that piece of code working in production since last year so pretty sure it was working fine, and we know it was not 0x prefixed because the other libraries we use would throw |
Can you include the |
Right, but I know that code has been there for years, and just now installed 4.0.43 locally from npm. So there is some disconnect. It was never supported, so the fact it is working for you means something we are not thinking of is going on... Can you verify in the
|
I assume it should be reproducible with valid private keys, like 9573fa33a57fee662a23bf60f1b1674364d99fb8dd2166b4ae470ce7ab20ed9f |
Something weird just happened... It started doing what you have. I will investigate further, because this is quite odd behaviour. Gimme a few minutes. I'll update this issue shortly. |
Sorry, I was looking at the wrong files when I sent those line numbers. That was the v2 code I'd installed to compare. One sec. Adding some tracing statements... |
You are absolutely correct! So sorry! My sample private key above was only 63 nibbles long, but the error indicated missing I just found a section in v4:
And now that I found it, I mentioned it to my partner and she has a slight recollection of that change because the version of Ganache at the time dumped out private keys without a Where are you getting your private key from? Is it still common for any recent tools to not Again, huge apologies for the inconvenience and my mistake. Thanks for your patience. :) |
(I see now that you had linked to that same portion of code above; thanks!) |
@yuetloo just noted the same thing re: Metamask... I'm contemplating adding support for |
This has been changed in 5.0.22. It should not reflect the behaviour in v4. Try it out and let me know if there are any issues. Hopefully in a years time, I don't have the same debate with someone else that it doesn't work that way. :p Thanks again for your patience! :) |
Closing this now. If you have any further issues, please feel free to re-open. Thanks!! :) |
hi. |
My ether node version 5.5.4 latest version. |
as per above chat my conclusion came that it require 4 version. |
Sorry, Prashant, how are you?
What I have to do now?
…On Tue, May 3, 2022 at 10:01 PM prashant sriharsh ***@***.***> wrote:
as per above chat my conclusion came that it require 4 version.
—
Reply to this email directly, view it on GitHub
<#1166 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXQUB22CTRIKRJ33JTZ673DVIIABHANCNFSM4T5ETORQ>
.
You are receiving this because you commented.Message ID: <ethers-io/ethers
.***@***.***>
|
me fine what's about you . in this issue i am getting same error while i tried to buy a nft from my unity game . |
i think u should change the version of npm ether to lower to 4 . i don't how to do it . i am also trying that |
I am still getting the same error? is there any plan to resolve it? |
If installing latest version of ethers is not helping |
While upgrading to Ethers V5, we ran into
This issue was brought up in
https://www.gitmemory.com/issue/ethers-io/ethers.js/994/674504533
I assume this is not an intended feature, as all other tools accept non 0x prefixed private keys, and prefixing 0x to the private key causes issues with bunch of other libraries, so it's a change specific for Ethers V5
Regardless of it's intended or not, this should have been included in the breaking change log https://docs.ethers.io/v5/migration/ethers-v4/#migration-v4--contracts
The text was updated successfully, but these errors were encountered: