solana
solana copied to clipboard
keygen: add the ability to use derivation path for new & grind commands
Problem
Impossible to use mnemonic from keygen in Phantom wallet and others.
Summary of Changes
Added ability to generate keypairs with mnemonic which is friendly with Phantom wallet and others.
This feature has been added for new
and grind
subcommands.
UPD. Now it looks:
solana-keygen new -o keypair.json prompt://?key=0/0
solana-keygen new -o keypair.json prompt://?full-path=m/44/2017/0/1
solana-keygen grind --use-mnemonic --starts-with a:1 prompt://?key=0/0
solana-keygen grind --use-mnemonic --starts-with a:1 prompt://?full-path=m/44/2017/0/1
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Hi there @solana-labs/community-pr-subscribers ! What's wrong with this PR? Do I need to add a new test for pub function? Or are you just too busy right now to be distracted by such features?)
Hey @mvines @t-nelson I'm sorry for pinging you, but could you please reply to my comments? It'll weekend and I'll have time to make some work.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
ping @solana-labs/community-pr-subscribers
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Codecov Report
Merging #21614 (11fdcb3) into master (8ba003a) will increase coverage by
0.1%
. The diff coverage is0.0%
.
:exclamation: Current head 11fdcb3 differs from pull request most recent head 79d4136. Consider uploading reports for the commit 79d4136 to get more accurate results
@@ Coverage Diff @@
## master #21614 +/- ##
=========================================
+ Coverage 81.8% 82.0% +0.1%
=========================================
Files 632 596 -36
Lines 167499 165242 -2257
Branches 322 0 -322
=========================================
- Hits 137169 135546 -1623
+ Misses 30217 29696 -521
+ Partials 113 0 -113
I have merged with the current master, and I have updated the code to use clap-v3-utils.
@t-nelson Could you please re-review?
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@t-nelson could you please review? Now it is as you suggested:
solana-keygen new -o keypair.json prompt://?key=0/0
solana-keygen new -o keypair.json prompt://?full-path=m/44/2017/0/1
solana-keygen grind --use-mnemonic --starts-with a:1 prompt://?key=0/0
solana-keygen grind --use-mnemonic --starts-with a:1 prompt://?full-path=m/44/2017/0/1
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Please don't close this 🙌
@solana-labs/community-pr-subscribers I'm so sorry to bore you, but it looks like t-nelson is too busy to rereview. So maybe you could assign someone else to review this PR?
I find it pretty odd that you're pulling the derivation from the prompt uri. I would recommend that you introduce a new derivation path cli argument for these subcommands. A lot of your changes in this PR add unnecessary complexity, this change should be much smaller, can you try creating a new more focused PR?
@jstarry Thank you for your answer! 🙏 🙏 🙏
At the begin of this PR it was as you suggest now:
solana-keygen new --use-derivation-path -o keypair.json
solana-keygen new --use-derivation-path m/44/2017/0/1 -o keypair.json
solana-keygen grind --use-mnemonic --use-derivation-path --starts-with a:1
solana-keygen grind --use-mnemonic --use-derivation-path m/44/2017/0/1 --starts-with a:1
mvines suggested just to remove use
.
But later t-nelson suggested to use prompt uri instead of additional arg (this pattern is used with other solana-keygen subcommands: recover, pubkey, verify) and I redid.
So now I'm confusion.
I agree with mvines' suggestion to drop use
but I disagree with t-nelson's suggestion to use prompt here. Please move forward with --derivation-path
(without use
as you had before) sorry for the back and forth!
Hello @jstarry I've done the suggestions. Could you please review?
@diman-io I was attempting to use this new version of the keygen program (built from source) to generate with a derivation path, but I continue to get a panic error when running the following commands:
# `new` subcommand
solana-keygen new --derivation-path -o ./keypair.json --force
# `grind` subcommand
solana-keygen grind --ignore-case --starts-with a:1 --derivation-path --use-mnemonic
NOTE: This is true for both the grind
and new
subcommands
The only way I have found to not get a panic, is if I also specify the --no-passphase
or --no-bip39-passphrase
. But there is no explicit mention of this requirement. Is there something I am missing/not understanding here, or is this in face a bug?
Update: This error seems to appear anytime I have the --use-mnemonic
flag
@nickfrosty I just built from the tip of master and your examples worked for me.
How did you build?
cd keygen && ../cargo build --release
?
@diman-io strange. I tried building both the full release from both the tip of master and the most the 1.14.11 release source using the same build command. Maybe it is something with my local computer?
The panic error keeps happening at the code below, both in grind
and new
:
acquire_passphrase_and_message(matches).unwrap()
This is the error I keep getting
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 6, kind: Uncategorized, message: "No such device or address" }',
Thoughts?
Edit: As another data point, it seems that any time I build for source, the keygen program always gives me this error when I get the prompt to enter a passphrase. The code panics before I am even able to enter an input. But it does print the prompt to the terminal
@diman-io I just realized that it was my VS code integrated terminal. For some reason it does not want to accept stdin and causes the panic. When I run the program in my actual terminal, no issues. Sorry about my troubles 🙃