diff --git a/account_manager/src/common.rs b/account_manager/src/common.rs index 529d3991e0..195f8c5d17 100644 --- a/account_manager/src/common.rs +++ b/account_manager/src/common.rs @@ -49,8 +49,7 @@ pub fn strip_off_newlines(mut bytes: Vec) -> Vec { } } bytes.truncate(bytes.len() - strip_off); - - bytes.to_vec() + bytes } #[cfg(test)] diff --git a/account_manager/src/validator/create.rs b/account_manager/src/validator/create.rs index 429110743b..d3379e583b 100644 --- a/account_manager/src/validator/create.rs +++ b/account_manager/src/validator/create.rs @@ -1,5 +1,5 @@ use crate::{ - common::{ensure_dir_exists, random_password}, + common::{ensure_dir_exists, random_password, strip_off_newlines}, SECRETS_DIR_FLAG, VALIDATOR_DIR_FLAG, }; use clap::{App, Arg, ArgMatches}; @@ -155,7 +155,7 @@ pub fn cli_run( let wallet_password = fs::read(&wallet_password_path) .map_err(|e| format!("Unable to read {:?}: {:?}", wallet_password_path, e)) - .map(|bytes| PlainText::from(bytes))?; + .map(|bytes| PlainText::from(strip_off_newlines(bytes)))?; let mgr = WalletManager::open(&wallet_base_dir) .map_err(|e| format!("Unable to open --{}: {:?}", BASE_DIR_FLAG, e))?; diff --git a/account_manager/src/wallet/create.rs b/account_manager/src/wallet/create.rs index b6c43e0b27..53bfc5693b 100644 --- a/account_manager/src/wallet/create.rs +++ b/account_manager/src/wallet/create.rs @@ -107,10 +107,7 @@ pub fn cli_run(matches: &ArgMatches, base_dir: PathBuf) -> Result<(), String> { let wallet_password = fs::read(&wallet_password_path) .map_err(|e| format!("Unable to read {:?}: {:?}", wallet_password_path, e)) - .map(|bytes| { - let bytes = strip_off_newlines(bytes); - PlainText::from(bytes) - })?; + .map(|bytes| PlainText::from(strip_off_newlines(bytes)))?; let wallet = mgr .create_wallet(name, wallet_type, &mnemonic, wallet_password.as_bytes())