Crate bip39

source · []
Expand description

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

Quickstart

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

/// create a new randomly generated mnemonic phrase
let mnemonic = Mnemonic::new(MnemonicType::Words12, Language::English);

/// get the phrase
let phrase: &str = mnemonic.phrase();
println!("phrase: {}", phrase);

/// get the HD wallet seed
let seed = Seed::new(&mnemonic, "");

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

// print the HD wallet seed as a hex string
println!("{:X}", seed);

Structs

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

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

Enums

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.

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