Add support for importing wallets using Electrum mnemonic phrases #22
Reference in New Issue
Block a user
Delete Branch "refs/pull/22/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is the format used by (older) Electron Cash wallets. It may be useful to users wishing to use their older EC wallets with Flowee Pay (such as myself).
Highlight of changes:
Both desktop and mobile UIs were updated.
Note: This requires Flowee/thehub#5 be merged.
Looking at this from the UX point of view:
user imports his seed phrase. The software checks validity and gives a thumbs up. In your changes it now also checks for electrum and gives a slightly different thumbs up.
Either way, in 99.997% of the cases it automatically imports without user interaction.
It is helpful to show that it detects an electrum type, because if the imported one falls in the 'other' category where it doesn't get correctly detected the user needs to detect that and check the checkbox. For no other reason than to make sure that the derivation path is set propertly.
After import is done, I fail to see any reason why Flowee Pay needs to hold onto the 'is electrum' boolean. It already shares the derivation path on the backup screen, which is implicitly the result of that boolean.
The actual conversion from mnemonic to hdmasterkey doesn't need this bool.
The fact that this is now automatically detected means there is no need for the user to 'backup' this boolean. So why keep it in the wallet?
Looking at changes in HDMasterkey, it looks like the boolean is needed to be persisted.
I did notice in Wallet_encryption.cpp that on line 250 there is another HDMasterKey::fromMnemonic() which may then need to have this bool added to the call.
Still, my UX point of view stands. I don't think that the UI has any need to show this boolean to the user after the import has completed.
For symmetry and because knowing the format is a key parameter to being able to even use the seed in the first place. High-level view:
wallet = restore(seed, format=bip39).In the electrum case you definitely need to be told again your seed was Electrum seed. Otherwise you will have a sad/bad/surprising time.
Without telling the user what format the original seed was in, they may be surprised when they try that seed in other software and if fails (or worse, it happens to be pass the BIP-39 checksum and they get a different wallet on restore!!).
It's helpful to be told it again. Just as it's helpful to be told what derivation path they have, what their seed is in the first place, etc.
By the way if you want to try an electrum seed with the UI here is one:
walnut ginger silent client kitchen wife old close round hire danger sceneIt even has history on it on BCH mainnet...
I don't have any seeds ready that I can share that happen to also match BIP39 checksums though.. but if you want one I can prepare one for you...
Yep you're right. Fixed.
Ok, pushed a new commit that implements your requested changes + also uses new API (enum for MnemonicType), etc.
Note we are persisting that enum's value directly to the wallet now, no longer a bool. What do you think about that?
Force-pushed a rebase to master (to take in the latest fixes).
Using one extra byte in the save-file in order to make the code clearer to read, sounds good to me.
I definitely agree enums are better in general for this -- was just concerned about safety in the code like if someone modifies the enum values or ordering... maybe they need to be documented with a comment and also hard-coded as:
Great idea, done;
TheHub: https://codeberg.org/Flowee/thehub/commit/1f57aef0df84bd8b9cdd0e96c0110f96881cf640
Pay: https://codeberg.org/Flowee/pay/commit/1cdd10ac6699e84272fb98b9c4e20a3e4149786d
Looks good to me!