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

[Docs][Qt][Tests][Wallet] Adding Seed phrases #2785

Closed
wants to merge 32 commits into from

Conversation

panleone
Copy link

@panleone panleone commented Dec 6, 2022

Coauthored with @Duddino
The aim of this pull request is adding seed phrases support with the BIP39 standard.

What I have done:

  • Added a function to generate a random 24 words seed phrase
  • Added a function to convert the seed phrase in the corresponding seed
  • Added a function to check if a seed phrase is valid
  • Implemented a qt interface
  • Implemented -seedphrase="words..." command on pivxd
  • wrote test units and functional tests
  • Implemented support for multi languages

EDIT:
we should discuss external compatibility in another PR

@panleone panleone marked this pull request as draft December 6, 2022 22:56
@Liquid369
Copy link
Member

Just getting into this now and as the start goes this is an concept uTACK!

A few things along the way for the basics of this before we get into the next TODO's

src/wallet/bip39_english.txt what if we do a JSON CPP file? IMO, it would look much cleaner. Do you like that idea?

In src/wallet.h we have the following enum class for "wallet versioning"

enum WalletFeature {
    FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output)

    FEATURE_WALLETCRYPT = 40000, // wallet encryption
    FEATURE_COMPRPUBKEY = 60000, // compressed public keys

    FEATURE_PRE_PIVX = 61000, // inherited version..

    // The following features were implemented in BTC but not in our wallet, we can simply skip them.
    // FEATURE_HD = 130000,  Hierarchical key derivation after BIP32 (HD Wallet)
    // FEATURE_HD_SPLIT = 139900, // Wallet with HD chain split (change outputs will use m/0'/1'/k)

    FEATURE_PRE_SPLIT_KEYPOOL = 169900, // Upgraded to HD SPLIT and can have a pre-split keypool

    FEATURE_SAPLING = 170000, // Upgraded to Saplings key manager.

    FEATURE_LATEST = FEATURE_SAPLING
};

We should add a new FEATURE_WORDLIST = 180000 as a possible idea.
Giving ourselves a differentiation in the working of this and to not confuse others.
Alongside having several "wallet update/upgrade functions" that we would want to account for in checking if our wallet is at the current installed version or if the user would like to update to a seed phrase
There is a starting param -upgradewallet in init.cpp line 31/93/94

For testing purposes, if we add RPC for validating/creating seeds would be helpful vs the current validation of a hard coded seed and make sure it can be repeated.

Partial review, before digging further I think these are some possible feature additions for this current portion to iron out and we can look into the other options.

Will update later here or in successive comment after testing!
Great start!

@panleone
Copy link
Author

panleone commented Dec 11, 2022

This is the UI that I created (there are still changes to be done)
newUI

@panleone
Copy link
Author

With this commit the QT part should be finished and functional... here a picture of the import seedphrase UI
import

@panleone
Copy link
Author

With this commit seedphrases are fully supported on pivxd as well.
with the arg:
./pivxd -seedphrase="hi this is a seed phrase..."
A seed phrase can be imported on pivxd and in particular this works only when the wallet is opened for the first time.
if instead the -seedphrase arg is not specified a new random seedphrase is generated and printed on console

@panleone panleone changed the title Adding Seed phrases [Docs][Qt][Tests][Wallet] Adding Seed phrases Dec 17, 2022
@panleone
Copy link
Author

panleone commented Feb 4, 2023

Sorry for jumping in this late in the conversation, but I am curious to know if you can import a bip39 seedphrase + password into the core wallet? Or is there a way to import the bip32 root key? Both should achieve the same result: output all the dirived addresses. If this is possible, is there any documentation? I have searched without success.

If this is an upcoming feature, when should users expect it to be implemented in the core program?

You will be able to import/generate bip39 seedphrases once this PR is merged and the new wallet version comes out (probably with 6.0 I'd say). The feature is basically completed/working I only need to design a better UI interface because it is too small. Also I'm currently working on DMNs (and I'm a Qt noob) so I don't know when I will finish.

For the bip32 AFAIK there is no "easy" way to import the master key or seed (as it should be since it is very easy to make mistake with a random sequence of bytes)

@3point14159
Copy link

@panleone, is there a way to do this through the console right now?

@panleone
Copy link
Author

panleone commented Feb 4, 2023

@panleone, is there a way to do this through the console right now?

At the moment (v5.5) the most you can do is choosing the hd seed with the rpc command: sethdseed, but beware that some action (for example locking the wallet with a password) will change the seed again.

@3point14159
Copy link

@panleone Understood. Better to wait for the next release. Any hopes of dropping a release candidate?

@3point14159
Copy link

@panleone I'm not seeing this anywhere in the milestone section, are you certain this will be making its way into the v6 release?

@panleone
Copy link
Author

@panleone I'm not seeing this anywhere in the milestone section, are you certain this will be making its way into the v6 release?

If other devs agree to release it into v6 yes

@3point14159
Copy link

@Fuzzbawls Think we can get this included in the next core release? Kinda feel like we are behind the curve with bip39, most other wallets can derive PIVX seed phrases, but not the core app... This would encourage those who've collected PIV on those mnemonic wallets to simply input them into the core if they feel like earning stake rewards on them and better decentralize the network for the rest of us. Seems like most of the work is already done, what's left that needs to happen to get this pushed out to production?

@Duddino
Copy link
Member

Duddino commented Feb 10, 2023

Because of the way child keys are derived, these seed phrases aren't compatible with other wallets

@3point14159
Copy link

@Duddino Interesting... but still a modern improvement over the current wallet file system. Looking at my dumpwallet over the past PIVX wallet overhauls has left my wallet a jumbled, semi-functional mess. I have PIV I can see on the block explorer that don't show up in my native wallet. I plan on creating a new wallet, once this here seedphrase mechanism is in production, and moving my PIV there for a (hopefully) better experience. Seems like this derivation method should handle wallet upgrades a little better... or (for stability's sake) should I create a new wallet the legacy way and start fresh from there?

@3point14159
Copy link

@panleone @Duddino glad to see the movement on this issue, can't wait to see it in production!

@panleone
Copy link
Author

Current status of this PR: Finally after 2 months I fixed all suggested changes, i.e. added support for multi languages seedphrases (at the moment there is italian and english) and improved the qt in general with the help of Liquid.

Copy link
Member

@Liquid369 Liquid369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 24b6009
Much better since the recent Qt fixes, I think we are ready now!

@3point14159
Copy link

@Liquid369 @Duddino @panleone I'm really looking forward to this release! I recently earned enough PIV for a masternode, but wallet was born 1H2017. Keep up the great work team, I think the PIVX DMN is going to be a game changer for decentralized governance. Who's going to jump on the podcasts to announce the changes? This should be news shared far and wide within the PoS community.

@Fuzzbawls
Copy link
Collaborator

This PR should be split up into at least 2 distinct PRs: first PR would implement the BIP39 functionality on the network level, part 2 would add GUI functionality.

Also, including multi-language hard-coded string translations directly in the source tree needs more consideration and evaluation.

@panleone
Copy link
Author

This PR should be split up into at least 2 distinct PRs: first PR would implement the BIP39 functionality on the network level, part 2 would add GUI functionality.

Also, including multi-language hard-coded string translations directly in the source tree needs more consideration and evaluation.

what's the alternative of including the words directly in the source code?

@3point14159
Copy link

Bonus points if we can get full language support for seedphrase generation AND full special character (extended ASCII) support for optional bip39 seed password. The team at Horizontal Systems have got it figured out for their wallet, so there is a template there:

horizontalsystems/unstoppable-wallet-android#5560

@panleone panleone closed this Feb 18, 2024
@panleone panleone removed their assignment Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants