From bbe61aeae8427836953428c5b00ca9ce2f297279 Mon Sep 17 00:00:00 2001 From: paulo Date: Thu, 29 Feb 2024 18:02:31 +0000 Subject: [PATCH] fix clear control characters from seed data --- src/crunch.rs | 6 ++++++ src/runtimes/polkadot.rs | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) 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,