Browse Source

Merge pull request #21 from adityapk00/master

Safely handler seed phrases
checkpoints
Denio 5 years ago
committed by GitHub
parent
commit
ee1eda9179
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      lib/src/lightwallet.rs

14
lib/src/lightwallet.rs

@ -173,8 +173,16 @@ impl LightWallet {
let mut system_rng = OsRng;
system_rng.fill(&mut seed_bytes);
} else {
seed_bytes.copy_from_slice(&Mnemonic::from_phrase(seed_phrase.expect("should have a seed phrase"),
Language::English).unwrap().entropy());
let phrase = match Mnemonic::from_phrase(seed_phrase.unwrap(), Language::English) {
Ok(p) => p,
Err(e) => {
let e = format!("Error parsing phrase: {}", e);
error!("{}", e);
return Err(io::Error::new(ErrorKind::InvalidData, e));
}
};
seed_bytes.copy_from_slice(&phrase.entropy());
}
// The seed bytes is the raw entropy. To pass it to HD wallet generation,
@ -1298,7 +1306,7 @@ impl LightWallet {
// Print info about the block every 10,000 blocks
if height % 10_000 == 0 {
match self.get_sapling_tree() {
Ok((h, hash, stree)) => info!("Sapling tree at height {}/{} - {}", h, hash, stree),
Ok((h, hash, stree)) => info!("Sapling tree at height\n({}, \"{}\",\"{}\"),", h, hash, stree),
Err(e) => error!("Couldn't determine sapling tree: {}", e)
}
}

Loading…
Cancel
Save