From 8cf83fae7dab1bc88bc62b36ed7c5527d642122f Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Tue, 7 Jan 2020 16:34:10 +0100 Subject: [PATCH] create function to add random sietch zaddr --- lib/src/lightwallet.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index ddd8e6b..a70cead 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -4,9 +4,7 @@ use std::cmp; use std::collections::{HashMap, HashSet}; use std::sync::{Arc, RwLock}; use std::io::{Error, ErrorKind}; - use rand::{Rng, rngs::OsRng}; - use log::{info, warn, error}; use protobuf::parse_from_bytes; @@ -199,7 +197,7 @@ impl LightWallet { seed_bytes.copy_from_slice(&phrase.entropy()); } - + // The seed bytes is the raw entropy. To pass it to HD wallet generation, // we need to get the 64 byte bip39 entropy let bip39_seed = bip39::Seed::new(&Mnemonic::from_entropy(&seed_bytes, Language::English).unwrap(), ""); @@ -466,7 +464,23 @@ impl LightWallet { } let pos = self.extsks.read().unwrap().len() as u32; - let bip39_seed = bip39::Seed::new(&Mnemonic::from_entropy(&self.seed, Language::English).unwrap(), ""); + + // Radnom Generator benutzen!!!!!! + + let mut rng = rand::thread_rng(); + let letter: String = rng.gen_range(b'A', b'Z').to_string(); + let number: String = rng.gen_range(0, 999999).to_string(); + // let combi: String = letter.to_string() + number.to_string(); + let s = format!("{}{:06}", letter, number); + //println!("{}", s); + + let my_string = String::from(s); + // let my_immutable_string = &my_string; //This is a &String type + let dust: &str = &my_string; //This is an &str type + + + + let bip39_seed = bip39::Seed::new(&Mnemonic::from_entropy(&self.seed, Language::English).unwrap(), dust); let (_extsk, _extfvk, address) = LightWallet::get_zaddr_from_bip39seed(&self.config, &bip39_seed.as_bytes(), pos);