Skip to content

Commit

Permalink
fix clear control characters from seed data
Browse files Browse the repository at this point in the history
  • Loading branch information
paulormart committed Feb 29, 2024
1 parent b792465 commit bbe61ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/crunch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -174,6 +175,11 @@ pub fn get_keypair_from_seed_file() -> Result<Keypair, CrunchError> {

// 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)?)
Expand Down
3 changes: 1 addition & 2 deletions src/runtimes/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bbe61ae

Please sign in to comment.