From 6bef2beba41219a0ecb185c5fe415b906b5ff8f1 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 14 Dec 2022 11:29:12 +1100 Subject: [PATCH] Allow export without password --- validator_client/src/http_api/keystores.rs | 2 +- validator_client/src/initialized_validators.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/validator_client/src/http_api/keystores.rs b/validator_client/src/http_api/keystores.rs index 51e8583753..c2d9b4d67f 100644 --- a/validator_client/src/http_api/keystores.rs +++ b/validator_client/src/http_api/keystores.rs @@ -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), diff --git a/validator_client/src/initialized_validators.rs b/validator_client/src/initialized_validators.rs index 6213304a44..2e9f83de0e 100644 --- a/validator_client/src/initialized_validators.rs +++ b/validator_client/src/initialized_validators.rs @@ -45,7 +45,7 @@ const USE_STDIN: bool = false; pub struct KeystoreAndPassword { pub keystore: Keystore, - pub password: ZeroizeString, + pub password: Option, } #[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)?;