Don't be offended I am asking too many questions, any way I could add shift in my code for the 8 words(non fixed positions), so if it permutes the first line containing 8 words, it goes down to the second line containing 8 words, it goes down to the third, fourth ........
I read this guy's code, he did it in his cpu code version.
my code
use eyre::Result;
use std::fs::OpenOptions;
use std::io::Write;
use bip39::Mnemonic;
use itertools::Itertools;
// Function to generate permutations
fn generate_permutations() -> Vec<Vec<&'static str>> {
let words = ["winter", "market", "lake", "easy", "song", "rib", "goat", "fork"];
let permutations = words.iter().permutations(words.len())
.map(|perm| perm.into_iter().map(|x| *x).collect::<Vec<&'static str>>())
.map(|mut perm| {
perm.insert(0, "dutch");
perm.insert(3, "fiber");
perm.insert(4, "fog");
perm.insert(11, "parrot");
perm
})
.collect::<Vec<Vec<&'static str>>>();
permutations
}
// Function to check if permutations produce valid mnemonics
fn check_valid(permutations: Vec<Vec<&'static str>>) -> Vec<String> {
let mut valid_phrases = Vec::new();
for perm in permutations {
let mnemonic_str = perm.join(" ");
if Mnemonic::parse_normalized(&mnemonic_str).is_ok() {
valid_phrases.push(mnemonic_str);
}
}
valid_phrases
}
// Function to check if a wallet contains the search string
fn contains_string(wallet: &str, search: &str) -> bool {
wallet.contains(search)
}
fn main() -> Result<()> {
let output_file_path = "ethers.txt";
let mut output_file = OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(output_file_path)?;
let index = 0u32;
let permutations = generate_permutations();
let valid_phrases = check_valid(permutations);
for phrase in valid_phrases {
// Build wallet from mnemonic phrase
let wallet = MnemonicBuilder::<English>::default()
.phrase(phrase.as_str())
.index(index)?
.build()?;
let wallet_address = format!("{:?}", wallet);
let search_string = "9df9939e6daf";
// Only write to the file if the wallet address contains the search string
if contains_string(&wallet_address, search_string) {
println!("True: {}", search_string);
// Write the phrase and wallet address to the output file
writeln!(output_file, "Phrase: {}, Wallet: {:?}", phrase, wallet)?;
}
}
Ok(())
}
// the lines i want to permute
const WORDS: [&str; 80] = [
round word cattle update winter goat expect fork
round word cattle update winter goat easy fork
round word cattle update winter goat will fork
round word cattle update winter goat lake fork
round word cattle update winter goat sing fork
round word cattle update winter goat song fork
round word cattle update winter goat title fork
round word cattle update winter goat original fork
round word cattle update winter goat task fork
round word cattle update winter goat unlock fork
]; ```