Skip to content
Snippets Groups Projects
Commit 292ab353 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

display cesium pubkey

parent a39465e6
No related branches found
No related tags found
1 merge request!15update to runtime 800
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
...@@ -8,9 +8,9 @@ pub enum Subcommand { ...@@ -8,9 +8,9 @@ pub enum Subcommand {
#[default] #[default]
#[clap(hide = true)] #[clap(hide = true)]
Nothing, Nothing,
/// Generate key pair with old style unsafe scrypt /// Analyse a base58 pubkey and gives it in all its form
Pubkey { id: String, pass: String }, Pubkey { pubkey: String },
/// Prompt /// Prompt for cesium input
Prompt, Prompt,
} }
...@@ -18,11 +18,19 @@ pub enum Subcommand { ...@@ -18,11 +18,19 @@ pub enum Subcommand {
pub async fn handle_command(_data: Data, command: Subcommand) -> Result<(), GcliError> { pub async fn handle_command(_data: Data, command: Subcommand) -> Result<(), GcliError> {
match command { match command {
Subcommand::Nothing => {} Subcommand::Nothing => {}
Subcommand::Pubkey { id, pass } => { Subcommand::Pubkey { pubkey } => {
let keypair = pair_from_cesium(id, pass); let raw_pubkey = bs58::decode(pubkey).into_vec().unwrap();
println!("Pubkey: {}", bs58::encode(keypair.pkey).into_string()); let raw_pubkey: [u8; 32] = if raw_pubkey.len() > 32 {
let address: AccountId = keypair.pkey.into(); return Err(GcliError::Input("invalid pubkey size".to_string()));
println!("Address: {}", address.to_string()); } else {
[vec![0; 32 - raw_pubkey.len()], raw_pubkey]
.concat()
.try_into()
.unwrap()
};
println!("Pubkey (hex): 0x{}", hex::encode(raw_pubkey));
let address: AccountId = sp_core::ed25519::Public(raw_pubkey).into();
println!("Address (SS58): {}", address.to_string());
} }
Subcommand::Prompt => { Subcommand::Prompt => {
let keypair = prompt_secret_cesium(); let keypair = prompt_secret_cesium();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment