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
......@@ -8,9 +8,9 @@ pub enum Subcommand {
#[default]
#[clap(hide = true)]
Nothing,
/// Generate key pair with old style unsafe scrypt
Pubkey { id: String, pass: String },
/// Prompt
/// Analyse a base58 pubkey and gives it in all its form
Pubkey { pubkey: String },
/// Prompt for cesium input
Prompt,
}
......@@ -18,11 +18,19 @@ pub enum Subcommand {
pub async fn handle_command(_data: Data, command: Subcommand) -> Result<(), GcliError> {
match command {
Subcommand::Nothing => {}
Subcommand::Pubkey { id, pass } => {
let keypair = pair_from_cesium(id, pass);
println!("Pubkey: {}", bs58::encode(keypair.pkey).into_string());
let address: AccountId = keypair.pkey.into();
println!("Address: {}", address.to_string());
Subcommand::Pubkey { pubkey } => {
let raw_pubkey = bs58::decode(pubkey).into_vec().unwrap();
let raw_pubkey: [u8; 32] = if raw_pubkey.len() > 32 {
return Err(GcliError::Input("invalid pubkey size".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 => {
let keypair = prompt_secret_cesium();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment