Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Require crypto scheme for insert-key
We should not "guess" the scheme as this can depend on the
implementation of the runtime etc.
  • Loading branch information
bkchr committed Oct 1, 2021
commit f7aecd8919c3a6928997f2523abed75e83921d41
16 changes: 11 additions & 5 deletions client/cli/src/commands/insert_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Implementation of the `insert` subcommand

use crate::{
utils, with_crypto_scheme, CryptoSchemeFlag, Error, KeystoreParams, SharedParams, SubstrateCli,
utils, with_crypto_scheme, CryptoScheme, Error, KeystoreParams, SharedParams, SubstrateCli,
};
use sc_keystore::LocalKeystore;
use sc_service::config::{BasePath, KeystoreConfig};
Expand Down Expand Up @@ -49,9 +49,14 @@ pub struct InsertKeyCmd {
#[structopt(flatten)]
pub keystore_params: KeystoreParams,

#[allow(missing_docs)]
#[structopt(flatten)]
pub crypto_scheme: CryptoSchemeFlag,
/// The cryptography scheme that should be used to generate the key out of the given URI.
#[structopt(
long,
value_name = "SCHEME",
possible_values = &CryptoScheme::variants(),
case_insensitive = true,
)]
pub scheme: CryptoScheme,
}

impl InsertKeyCmd {
Expand All @@ -69,7 +74,7 @@ impl InsertKeyCmd {
let (keystore, public) = match self.keystore_params.keystore_config(&config_dir)? {
(_, KeystoreConfig::Path { path, password }) => {
let public = with_crypto_scheme!(
self.crypto_scheme.scheme,
self.scheme,
to_vec(&suri, password.clone())
)?;
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::open(path, password)?);
Expand Down Expand Up @@ -161,6 +166,7 @@ mod tests {
"test",
"--suri",
&uri,
"--scheme=sr25519"
]);
assert!(inspect.run(&Cli).is_ok());

Expand Down