-
Notifications
You must be signed in to change notification settings - Fork 54
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
641 Validate Mnemonic Words on Wallet Import #739
641 Validate Mnemonic Words on Wallet Import #739
Conversation
JoinMarket is hardcoded to English wordlist, it uses old code from Electrum. https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/239ac4689a61e769fa17f8e9ef2688b835d0748b/src/jmclient/old_mnemonic.py |
Hey @zmjohnso! Nice 🚀 My 2 sats:
|
Thanks for that reference @kristapsk! But I am still a bit confused how jm is doing the check, since that word list does not seem to contain everything in the bip39 wordlist, i.e., "abandon". I will try to understand this better. Thanks again. @theborakompanioni Yes, I completely agree with your first point. I have added a hardcoded version of the bip39 wordlist and removed the bip39 package. On your second point: currently the user can still continue through the workflow to import a wallet even if the UI shows the word as "invalid". Then after reviewing the words and clicking the final "import" button, the jm api will throw an error if it is not a valid mnemonic phrase. I think this workflow currently makes sense as is. We should allow the user to continue and ultimately this just serves as a visual check if the user has a typo, but the final validation happens on the api. |
From API perspective you either give completely correct world list or get error back. |
Very reasonable! 👍 Only little nit regarding the code is that now the Otherwise, let's merge this soon! Thank you so much @zmjohnso Great work. Simple and clean. |
@theborakompanioni So I added the |
Made some small adaptions (taking into account the |
Fixes #641.
To check for each word, I simply added the bip39 javascript package to the project to get the full wordlists, then check that the mnemonic word input is contained within the list. I've defaulted the check against the English word list since it seems that the joinmarket api also defaults to the English words. There might be a better way to do this? I'm not exactly sure how the jm api is doing the check.
After: