Strip new lines in validator create (#1214)

This commit is contained in:
Michael Sproul 2020-05-28 11:26:24 +10:00 committed by GitHub
parent 6383c95f8b
commit 7d897a0519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 8 deletions

View File

@ -49,8 +49,7 @@ pub fn strip_off_newlines(mut bytes: Vec<u8>) -> Vec<u8> {
} }
} }
bytes.truncate(bytes.len() - strip_off); bytes.truncate(bytes.len() - strip_off);
bytes
bytes.to_vec()
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,5 +1,5 @@
use crate::{ use crate::{
common::{ensure_dir_exists, random_password}, common::{ensure_dir_exists, random_password, strip_off_newlines},
SECRETS_DIR_FLAG, VALIDATOR_DIR_FLAG, SECRETS_DIR_FLAG, VALIDATOR_DIR_FLAG,
}; };
use clap::{App, Arg, ArgMatches}; use clap::{App, Arg, ArgMatches};
@ -155,7 +155,7 @@ pub fn cli_run<T: EthSpec>(
let wallet_password = fs::read(&wallet_password_path) let wallet_password = fs::read(&wallet_password_path)
.map_err(|e| format!("Unable to read {:?}: {:?}", wallet_password_path, e)) .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) let mgr = WalletManager::open(&wallet_base_dir)
.map_err(|e| format!("Unable to open --{}: {:?}", BASE_DIR_FLAG, e))?; .map_err(|e| format!("Unable to open --{}: {:?}", BASE_DIR_FLAG, e))?;

View File

@ -107,10 +107,7 @@ pub fn cli_run(matches: &ArgMatches, base_dir: PathBuf) -> Result<(), String> {
let wallet_password = fs::read(&wallet_password_path) let wallet_password = fs::read(&wallet_password_path)
.map_err(|e| format!("Unable to read {:?}: {:?}", wallet_password_path, e)) .map_err(|e| format!("Unable to read {:?}: {:?}", wallet_password_path, e))
.map(|bytes| { .map(|bytes| PlainText::from(strip_off_newlines(bytes)))?;
let bytes = strip_off_newlines(bytes);
PlainText::from(bytes)
})?;
let wallet = mgr let wallet = mgr
.create_wallet(name, wallet_type, &mnemonic, wallet_password.as_bytes()) .create_wallet(name, wallet_type, &mnemonic, wallet_password.as_bytes())