Struct bdk::keys::bip39::Mnemonic

source ·
pub struct Mnemonic { /* private fields */ }
Available on crate feature keys-bip39 only.
Expand description

A mnemonic code.

The core::str::FromStr implementation will try to determine the language of the mnemonic from all the supported languages. (Languages have to be explicitly enabled using the Cargo features.)

Supported number of words are 12, 18 and 24.

Implementations

Create a new Mnemonic in the specified language from the given entropy. Entropy must be a multiple of 32 bits (4 bytes) and 128-256 bits in length.

Create a new English Mnemonic from the given entropy. Entropy must be a multiple of 32 bits (4 bytes) and 128-256 bits in length.

Generate a new Mnemonic in the given language with the given randomness source. For the different supported word counts, see documentation on Mnemonic.

Example:

extern crate rand;
extern crate bip39;

use bip39::{Mnemonic, Language};

let mut rng = rand::thread_rng();
let m = Mnemonic::generate_in_with(&mut rng, Language::English, 24).unwrap();

Get the language of the Mnemonic.

Get an iterator over the words.

Determine the language of the mnemonic.

NOTE: This method only guarantees that the returned language is the correct language on the assumption that the mnemonic is valid. It does not itself validate the mnemonic.

Some word lists don’t guarantee that their words don’t occur in other word lists. In the extremely unlikely case that a word list can be interpreted in multiple languages, an Error::AmbiguousLanguages is returned, containing the possible languages.

Parse a mnemonic in normalized UTF8 in the given language.

Parse a mnemonic in normalized UTF8.

Parse a mnemonic in the given language.

Parse a mnemonic and detect the language from the enabled languages.

Get the number of words in the mnemonic.

Convert to seed bytes with a passphrase in normalized UTF8.

Convert to seed bytes.

Convert the mnemonic back to the entropy used to generate it. The return value is a byte array and the size. Use Mnemonic::to_entropy (needs std) to get a Vec.

Convert the mnemonic back to the entropy used to generate it.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Consume self and turn it into an ExtendedKey Read more
Consume self and turn it into a DescriptorKey by adding the extra metadata, such as key origin and derivation path Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Type specifying the amount of entropy required e.g. [u8;32]
Extra options required by the generate_with_entropy
Returned error in case of failure
Generate a key given the extra options and the entropy
Generate a key given the options with a random entropy
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.