Crate bip39 [] [src]

This is a Rust implementation of the bip39 standard for Bitcoin HD wallet mnemonic phrases.

Quickstart

use bip39::{Mnemonic, MnemonicType, Language, Seed};

/// determines the number of words in the mnemonic phrase
let mnemonic_type = MnemonicType::Type12Words;

/// create a new randomly generated mnemonic phrase
let mnemonic = match Mnemonic::new(mnemonic_type, Language::English, "") {
    Ok(b) => b,
    Err(e) => { println!("e: {}", e); return }
};

/// get the phrase as a string
let phrase = mnemonic.get_string();
println!("phrase: {}", phrase);

/// get the HD wallet seed
let seed = mnemonic.get_seed();

// get the HD wallet seed as raw bytes
let seed_bytes: &[u8] = seed.as_ref();

// get the HD wallet seed as a hex string
let seed_hex: &str = seed.as_hex();

// get an owned Seed instance
let owned_seed: Seed = seed.to_owned();

Structs

Error

The Error type.

Mnemonic

The primary type in this crate, most tasks require creating or using one.

Seed

The secret value used to derive HD wallet addresses from a Mnemonic phrase.

Enums

ErrorKind

The kind of an error.

Language

The language determines which words will be used in a mnemonic phrase, but also indirectly determines the binary value of each word when a Mnemonic is turned into a Seed.

MnemonicType

Determines the number of words that will be present in a Mnemonic phrase