fn private_key_from_mnemonic(mnemonic_words: &str) -> Result<ExtendedPrivKey, Error> {
    let mnemonic = Mnemonic::from_phrase(mnemonic_words, Language::English)
        .map_err(|e| Kind::InvalidMnemonic.context(e))?;

    let seed = Seed::new(&mnemonic, "");

    // Get Private Key from seed and standard derivation path
    let hd_path = StandardHDPath::try_from("m/44'/118'/0'/0/0").unwrap();
    let private_key = ExtendedPrivKey::new_master(Network::Bitcoin, seed.as_bytes())
        .and_then(|k| k.derive_priv(&Secp256k1::new(), &DerivationPath::from(hd_path)))
        .map_err(|e| Kind::PrivateKey.context(e))?;

    Ok(private_key)
}
/// Decode an extended private key from a mnemonic
Decode an extended private key from a mnemonic
Decode an extended private key from a mnemonic
fn private_key_from_mnemonic(mnemonic_words: &str) -> Result<ExtendedPrivKey, Error> {
    let mnemonic = Mnemonic::from_phrase(mnemonic_words, Language::English)
        .map_err(|e| Kind::InvalidMnemonic.context(e))?;
    let seed = Seed::new(&mnemonic, "");
    // Get Private Key from seed and standard derivation path
    let hd_path = StandardHDPath::try_from("m/44'/118'/0'/0/0").unwrap();
    let private_key = ExtendedPrivKey::new_master(Network::Bitcoin, seed.as_bytes())
        .and_then(|k| k.derive_priv(&Secp256k1::new(), &DerivationPath::from(hd_path)))
        .map_err(|e| Kind::PrivateKey.context(e))?;
    Ok(private_key)
}
fn private_key_from_mnemonic ( mnemonic_words : & str ) -> Result < ExtendedPrivKey , Error > { let mnemonic = Mnemonic :: from_phrase ( mnemonic_words , Language :: English ) . map_err ( | e | Kind :: InvalidMnemonic . context ( e ) ) ? ; let seed = Seed :: new ( & mnemonic , " " ) ; // Get Private Key from seed and standard derivation path let hd_path = StandardHDPath :: try_from ( " " ) . unwrap ( ) ; let private_key = ExtendedPrivKey :: new_master ( Network :: Bitcoin , seed . as_bytes ( ) ) . and_then ( | k | k . derive_priv ( & Secp256k1 :: new ( ) , & DerivationPath :: from ( hd_path ) ) ) . map_err ( | e | Kind :: PrivateKey . context ( e ) ) ? ; Ok ( private_key ) }
Decode an extended private key from a mnemonic
Decode an extended private key from a mnemonic
mnemonic_words
&str
mnemonic_words
&str