Struct bip39::bip39::Bip39 [] [src]

pub struct Bip39 {
    pub mnemonic: String,
    pub seed: Vec<u8>,
    pub lang: Language,
}

Fields

Methods

impl Bip39
[src]

Generates a new Bip39 struct

When returned, the struct will be filled in with the phrase and the seed value as 64 bytes raw

Example

use bip39::{Bip39, KeyType, Language};

let kt = KeyType::for_word_length(12).unwrap();

let bip39 = match Bip39::new(&kt, Language::English, "") {
    Ok(b) => b,
    Err(e) => { println!("e: {}", e); return }
};

let phrase = &bip39.mnemonic;
let seed = &bip39.seed;
println!("phrase: {}", phrase);

Create a Bip39 struct from an existing mnemonic phrase

The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039

Example

use bip39::{Bip39, KeyType, Language};

let test_mnemonic = "park remain person kitchen mule spell knee armed position rail grid ankle";

let b = Bip39::from_mnemonic(test_mnemonic, Language::English, "").unwrap();

Validate a mnemonic phrase

The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039

Example

use bip39::{Bip39, KeyType, Language};

let test_mnemonic = "park remain person kitchen mule spell knee armed position rail grid ankle";

match Bip39::validate(test_mnemonic, &Language::English) {
    Ok(_) => { println!("valid: {}", test_mnemonic); },
    Err(e) => { println!("e: {}", e); return }
}

Trait Implementations

impl Debug for Bip39
[src]

Formats the value using the given formatter.