diff --git a/src/crunch.rs b/src/crunch.rs index 3fb3c2b..bba14ce 100644 --- a/src/crunch.rs +++ b/src/crunch.rs @@ -31,6 +31,7 @@ use crate::runtimes::{ use async_std::task; use log::{debug, error, info, warn}; use rand::Rng; +use regex::Regex; use serde::Deserialize; use std::{convert::TryInto, fs, result::Result, str::FromStr, thread, time}; @@ -174,6 +175,11 @@ pub fn get_keypair_from_seed_file() -> Result { // load data from seed file let data = fs::read_to_string(config.seed_path)?; + + // clear control characters from data + let re = Regex::new(r"[\x00-\x1F]").unwrap(); + let data = re.replace_all(&data.trim(), ""); + // parse data into a secret let uri = SecretUri::from_str(&data)?; Ok(Keypair::from_uri(&uri)?) diff --git a/src/runtimes/polkadot.rs b/src/runtimes/polkadot.rs index d9670fd..b5a1797 100644 --- a/src/runtimes/polkadot.rs +++ b/src/runtimes/polkadot.rs @@ -35,8 +35,7 @@ use crate::stats; use async_recursion::async_recursion; use log::{debug, info, warn}; use std::{ - cmp, convert::TryFrom, convert::TryInto, result::Result, str::FromStr, thread, - time, + cmp, convert::TryFrom, convert::TryInto, result::Result, str::FromStr, thread, time, }; use subxt::{ error::DispatchError,