Allow export without password

This commit is contained in:
Paul Hauner
2022-12-14 11:29:12 +11:00
parent bbcf7b857e
commit 6bef2beba4
2 changed files with 5 additions and 5 deletions

View File

@@ -333,7 +333,7 @@ fn delete_single_keystore(
Ok(Some(keystore_and_password)) => Ok(SingleExportKeystoresResponse {
status: Status::ok(DeleteKeystoreStatus::Deleted),
validating_keystore: Some(KeystoreJsonStr(keystore_and_password.keystore)),
validating_keystore_password: Some(keystore_and_password.password),
validating_keystore_password: keystore_and_password.password,
}),
Ok(None) => Ok(SingleExportKeystoresResponse {
status: Status::ok(DeleteKeystoreStatus::Deleted),

View File

@@ -45,7 +45,7 @@ const USE_STDIN: bool = false;
pub struct KeystoreAndPassword {
pub keystore: Keystore,
pub password: ZeroizeString,
pub password: Option<ZeroizeString>,
}
#[derive(Debug)]
@@ -103,7 +103,6 @@ pub enum Error {
/// Unable to apply an action to a validator.
InvalidActionOnValidator,
UnableToReadValidatorPassword(String),
MissingKeystorePassword,
UnableToReadKeystoreFile(eth2_keystore::Error),
}
@@ -561,10 +560,11 @@ impl InitializedValidators {
..
} if is_local_keystore => {
let password = match (voting_keystore_password, voting_keystore_password_path) {
(Some(password), _) => password.clone(),
(Some(password), _) => Some(password.clone()),
(_, Some(path)) => read_password_string(path)
.map(Option::Some)
.map_err(Error::UnableToReadValidatorPassword)?,
(None, None) => return Err(Error::MissingKeystorePassword),
(None, None) => None,
};
let keystore = Keystore::from_json_file(voting_keystore_path)
.map_err(Error::UnableToReadKeystoreFile)?;