-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add mnemonic generation for new wallets #1635
Conversation
Rebased #1438 atop main and then linked it in to wallet generation w/ optional passphrase. I think this gets us going and we can improve things atop this. |
4057b2b
to
6b120d0
Compare
acf661f
to
18a2b2a
Compare
a46b58b
to
0546831
Compare
89b52ef
to
24d158c
Compare
This is not working on initial testnets, so some debugging to do here |
#[allow(dead_code)] // as yet unused, will be used soon | ||
/// Derive an xorname from the mnemonic for the account to store data. | ||
pub(crate) fn account_root_xorname(mnemonic: bip39::Mnemonic, passphrase: &str) -> Result<XorName> { | ||
let seed = mnemonic.to_seed(passphrase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall put the following block of code into a separate private helper function, then be used by both account_wallet_secret_key
and account_root_xorname
functions:
fn derived_key_bytes(mnemonic, passphrase) -> {
let seed = mnemonic.to_seed(passphrase);
let root_sk =
eip2333::derive_master_sk(&seed).map_err(|_err| Error::InvalidMnemonicSeedPhrase)?;
let derived_key = eip2333::derive_child_sk(root_sk, ACCOUNT_WALLET_DERIVATION);
derived_key.serialize()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly not sure on this, purely because the return type is... large.
@@ -203,6 +216,19 @@ async fn respond_to_gift_request( | |||
key: String, | |||
semaphore: Arc<Semaphore>, | |||
) -> std::result::Result<impl Reply, std::convert::Infallible> { | |||
let faucet_root = get_faucet_data_dir(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this block of loading wallet
code can be a separate private helper function?
seems appeared duplicatedly couple of times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's only twice in that file, not sure it's necessary atm.
Ok(key) => { | ||
if let Some(passed_key) = main_key { | ||
if key.secret_key() != passed_key.secret_key() { | ||
warn!("main_key passed to load_from_path_and_key, but a key was found in the wallet dir. Using the one found in the wallet dir."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds bit risky.
shall we raise an error and terminate the work instead ?
if user do forgot main_key, he can still continue by passing down a None ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was debating this, I think it's a follow up. Changing the internal load fn to not do this and error is like 80% of this PR, so not super keen to start in on more in this :D
Allows for reuse in faucet works and proper ci usage. Makes the account packet tooling more client layer there.
Use account packet helpers to generate wallet reliably now errors out if no wallet is found
Description
reviewpad:summary