#mnemonic #bip-39 #bitcoin

cpc-bip39

A Rust implementation of BIP-0039

1 unstable release

Uses old Rust 2015

0.1.0 Dec 17, 2022

#36 in #bip-39


Used in cpchain-rust-sdk

MIT/Apache

67KB
659 lines

BIP 39


lib.rs:

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);

Dependencies

~4.5MB
~74K SLoC