-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added "use seed phrase" method to create an implicit account (#153
- Loading branch information
Showing
5 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/commands/account/create_account/create_implicit_account/seed_phrase.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use inquire::Text; | ||
use std::str::FromStr; | ||
|
||
#[derive(Debug, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(context = crate::GlobalContext)] | ||
pub struct SeedPhrase { | ||
///Enter the seed-phrase for this account | ||
master_seed_phrase: String, | ||
#[interactive_clap(long)] | ||
#[interactive_clap(skip_default_input_arg)] | ||
seed_phrase_hd_path: crate::types::slip10::BIP32Path, | ||
#[interactive_clap(named_arg)] | ||
///Specify a folder to save the implicit account file | ||
save_to_folder: super::SaveToFolder, | ||
} | ||
|
||
impl SeedPhrase { | ||
pub fn input_seed_phrase_hd_path( | ||
_context: &crate::GlobalContext, | ||
) -> color_eyre::eyre::Result<crate::types::slip10::BIP32Path> { | ||
Ok(crate::types::slip10::BIP32Path::from_str( | ||
&Text::new("Enter seed phrase HD Path (if you not sure leave blank for default)") | ||
.with_initial_value("m/44'/397'/0'") | ||
.prompt() | ||
.unwrap(), | ||
) | ||
.unwrap()) | ||
} | ||
|
||
pub fn get_key_pair_properties( | ||
&self, | ||
) -> color_eyre::eyre::Result<crate::common::KeyPairProperties> { | ||
crate::common::get_key_pair_properties_from_seed_phrase( | ||
self.seed_phrase_hd_path.clone(), | ||
self.master_seed_phrase.clone(), | ||
) | ||
} | ||
|
||
pub fn get_folder_path(&self) -> std::path::PathBuf { | ||
self.save_to_folder.get_folder_path() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters