mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 04:35:41 +00:00
Require crypto scheme for insert-key (#9909)
* Require crypto scheme for `insert-key` We should not "guess" the scheme as this can depend on the implementation of the runtime etc. * FMT
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
//! Implementation of the `insert` subcommand
|
//! Implementation of the `insert` subcommand
|
||||||
|
|
||||||
use crate::{
|
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_keystore::LocalKeystore;
|
||||||
use sc_service::config::{BasePath, KeystoreConfig};
|
use sc_service::config::{BasePath, KeystoreConfig};
|
||||||
@@ -49,9 +49,14 @@ pub struct InsertKeyCmd {
|
|||||||
#[structopt(flatten)]
|
#[structopt(flatten)]
|
||||||
pub keystore_params: KeystoreParams,
|
pub keystore_params: KeystoreParams,
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
/// The cryptography scheme that should be used to generate the key out of the given URI.
|
||||||
#[structopt(flatten)]
|
#[structopt(
|
||||||
pub crypto_scheme: CryptoSchemeFlag,
|
long,
|
||||||
|
value_name = "SCHEME",
|
||||||
|
possible_values = &CryptoScheme::variants(),
|
||||||
|
case_insensitive = true,
|
||||||
|
)]
|
||||||
|
pub scheme: CryptoScheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InsertKeyCmd {
|
impl InsertKeyCmd {
|
||||||
@@ -68,10 +73,7 @@ impl InsertKeyCmd {
|
|||||||
|
|
||||||
let (keystore, public) = match self.keystore_params.keystore_config(&config_dir)? {
|
let (keystore, public) = match self.keystore_params.keystore_config(&config_dir)? {
|
||||||
(_, KeystoreConfig::Path { path, password }) => {
|
(_, KeystoreConfig::Path { path, password }) => {
|
||||||
let public = with_crypto_scheme!(
|
let public = with_crypto_scheme!(self.scheme, to_vec(&suri, password.clone()))?;
|
||||||
self.crypto_scheme.scheme,
|
|
||||||
to_vec(&suri, password.clone())
|
|
||||||
)?;
|
|
||||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::open(path, password)?);
|
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::open(path, password)?);
|
||||||
(keystore, public)
|
(keystore, public)
|
||||||
},
|
},
|
||||||
@@ -161,6 +163,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
"--suri",
|
"--suri",
|
||||||
&uri,
|
&uri,
|
||||||
|
"--scheme=sr25519",
|
||||||
]);
|
]);
|
||||||
assert!(inspect.run(&Cli).is_ok());
|
assert!(inspect.run(&Cli).is_ok());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user