Skip to content
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

feat(rpc): GetMnemonic #2000

Merged
merged 1 commit into from
Nov 23, 2020
Merged

feat(rpc): GetMnemonic #2000

merged 1 commit into from
Nov 23, 2020

Conversation

sangaman
Copy link
Collaborator

This adds a new rpc call GetMnemonic that can be used to retrieve the master seed mnemonic for xud at runtime after an xud node has been created.

Closes #1982.

@sangaman sangaman added grpc gRPC API command line (CLI) Relating to the command line interface tools labels Nov 20, 2020
@sangaman sangaman self-assigned this Nov 20, 2020
@ghost
Copy link

ghost commented Nov 20, 2020

utACK

@kilrau kilrau requested review from a user and raladev November 20, 2020 11:02
@sangaman
Copy link
Collaborator Author

The output just looks like this currently, I'm open to suggestions on if we want to include any additional information or formatting.

$ ./bin/xucli mnemonic
above moon armor scale valid accuse inject choose unable normal toy exit ostrich doctor laptop desert lady romance ginger start tomato orbit february swim

@kilrau
Copy link
Contributor

kilrau commented Nov 20, 2020

Looking at the current cli commands I'd change to getmnemonic to follow the convention

@sangaman
Copy link
Collaborator Author

Here's a quick primer on the aezeed format we're using for our mnemonic, and why the mnemonic we get will be different from the original creation of the seed and different from each time we get the mnemonic at runtime.

The deciphered aezeed data is a 1 byte payload, 2 byte birthday/timestamp, and 16 bytes of entropy. We store that to our node key file encrypted on the disk, so all this is preserved, but we don't store the enciphered seed anywhere. The mnemonic represents the 33 byte enciphered seed, which includes the deciphered key plus a salt and checksum.

The salt is going to to change every time we encipher the deciphered seed to recreate the mnemonic. So we'll get a different mnemonic every time, which may appear unusual to people used to conventional bip39 mnemonic seeds, but it's in fact a feature and not a bug.

@kilrau
Copy link
Contributor

kilrau commented Nov 20, 2020

Thanks for the explainer @sangaman , I'd say let's leave the behavior as is and as just discussed add a hint (at least on the cli) for the user to know that this mnemonic will be different every time but still always recovers the same funds.

@kilrau
Copy link
Contributor

kilrau commented Nov 23, 2020

Can we wrap this up today? @sangaman

Missing before @raladev can start testing again:

@kilrau
Copy link
Contributor

kilrau commented Nov 23, 2020

@sangaman
Copy link
Collaborator Author

New output:

$ ./bin/xucli getmnemonic
----------------------BEGIN XUD SEED---------------------
 1. abstract    2. future      3. flavor      4. aim       
 5. amount      6. okay        7. hidden      8. orange    
 9. combine    10. collect    11. liar       12. dish      
13. fossil     14. sort       15. nest       16. elbow     
17. bachelor   18. combine    19. inherit    20. salon     
21. annual     22. there      23. actress    24. spoil     
-----------------------END XUD SEED----------------------


Please write down your 24 word mnemonic. It will allow you to recover your xud node key and on-chain funds for the initialized wallets listed above should you forget your password or lose your device. Off-chain funds in channels can NOT be recovered with it and must be backed up and recovered separately. Keep it somewhere safe, it is your ONLY backup in case of data loss.


Note that this mnemonic is not the same as the mnemonic displayed when this xud node was first created. Xud uses aezeed which is salted with random bytes, xud does not store the salt or the mnemonic words. Each time xud regenerates the mnemonic, it uses a new salt so that the mnemonic is different, but it still restores the same xud node key and the same underlying wallet addresses.

@kilrau
Copy link
Contributor

kilrau commented Nov 23, 2020

Can short from

Note that this mnemonic is not the same as the mnemonic displayed when this xud node was first created. Xud uses aezeed which is salted with random bytes, xud does not store the salt or the mnemonic words. Each time xud regenerates the mnemonic, it uses a new salt so that the mnemonic is different, but it still restores the same xud node key and the same underlying wallet addresses.

->

Note that this mnemonic changes each time xud regenerates the mnemonic, but it still restores the same xud node key and the same underlying wallets.

Apart from that looking good.

@kilrau
Copy link
Contributor

kilrau commented Nov 23, 2020

*You can leave the details about why the mnemonic changes as in-code comment for that sentence.

This adds a new rpc call `GetMnemonic` that can be used to retrieve
the master seed mnemonic for xud at runtime after an xud node has been
created.

Closes #1982.
@sangaman
Copy link
Collaborator Author

Done, kept the message in the shorter form you suggested but tweaked it just a bit more:

Note that this mnemonic changes each time it is regenerated by xud, but it still restores the same xud node key and underlying wallets

@kilrau
Copy link
Contributor

kilrau commented Nov 23, 2020

Please give this another spin @raladev

@sangaman sangaman merged commit 9d0e470 into master Nov 23, 2020
@sangaman sangaman deleted the show-mnemonic branch November 23, 2020 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command line (CLI) Relating to the command line interface tools grpc gRPC API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support displaying mnemonic again
3 participants