Struct bdk::keys::bip39::Mnemonic [−][src]
pub struct Mnemonic { /* fields omitted */ }
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 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
Consume self
and turn it into an ExtendedKey
Read more
fn into_descriptor_key(
self,
source: Option<KeySource>,
derivation_path: DerivationPath
) -> Result<DescriptorKey<Ctx>, KeyError>
fn into_descriptor_key(
self,
source: Option<KeySource>,
derivation_path: DerivationPath
) -> Result<DescriptorKey<Ctx>, KeyError>
Consume self
and turn it into a DescriptorKey
by adding the extra metadata, such as
key origin and derivation path Read more
pub fn deserialize<D>(
deserializer: D
) -> Result<Mnemonic, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<Mnemonic, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
fn generate_with_entropy(
(word_count, language): Self::Options,
entropy: Self::Entropy
) -> Result<GeneratedKey<Self, Ctx>, Self::Error>
fn generate_with_entropy(
(word_count, language): Self::Options,
entropy: Self::Entropy
) -> Result<GeneratedKey<Self, Ctx>, Self::Error>
Generate a key given the extra options and the entropy
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
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Mnemonic
impl UnwindSafe for Mnemonic
Blanket Implementations
Mutably borrows from an owned value. Read more