Skip to main content

Crate bip0039

Crate bip0039 

Source
Expand description

§bip0039

Another Rust implementation of BIP-0039 standard.

§Usage

§Compile-time language selection

use bip0039::{Count, English, Mnemonic};

// Generate an English mnemonic with 12 words randomly
let mnemonic = <Mnemonic<English>>::generate(Count::Words12);
// Or use the default generic type (English).
let mnemonic = <Mnemonic>::generate(Count::Words12);
println!("phrase: {}", mnemonic.phrase());

// Generate the HD wallet seed from the mnemonic and the passphrase.
let seed = mnemonic.to_seed("");
assert_eq!(seed.len(), 64);
println!("seed: {}", const_hex::encode(seed));

§Runtime language selection

use bip0039::{AnyLanguage, AnyMnemonic, BuiltInLanguage, Count, English};

// Generate an English mnemonic with 12 words randomly
let mnemonic = AnyMnemonic::generate(BuiltInLanguage::English, Count::Words12);
assert_eq!(mnemonic.language(), AnyLanguage::of::<English>());
println!("phrase: {}", mnemonic.phrase());

// Generate the HD wallet seed from the mnemonic and the passphrase.
let seed = mnemonic.to_seed("");
assert_eq!(seed.len(), 64);
println!("seed: {}", const_hex::encode(seed));

Re-exports§

pub use self::language::*;

Modules§

language
Supported languages for BIP-0039.

Structs§

AnyMnemonic
A mnemonic representation with a runtime-selected language.
Mnemonic
A mnemonic representation.

Enums§

Count
Determines the words count that will be present in a Mnemonic phrase.
Error
The BIP-0039 error.