pub struct Mnemonic(/* private fields */);
Expand description
BIP-39
24-word mnemonic phrase compatible with the Android and iOS mobile wallets.
Implementations§
source§impl Mnemonic
impl Mnemonic
sourcepub fn from_words(words: Vec<String>) -> Result<Self>
pub fn from_words(words: Vec<String>) -> Result<Self>
Constructs a Mnemonic
from a 24-word list.
§Errors
- if the mnemonic has an invalid length.
- if the mnemonic uses invalid words.
- if the mnemonic has an invalid checksum.
sourcepub fn generate_12() -> Self
pub fn generate_12() -> Self
Generate a new 12 word Mnemonic
from the BIP-39 standard English word list.
sourcepub fn generate_24() -> Self
pub fn generate_24() -> Self
Generate a new 24 word Mnemonic
from the BIP-39 standard English word list.
sourcepub fn to_legacy_private_key(&self) -> Result<PrivateKey>
pub fn to_legacy_private_key(&self) -> Result<PrivateKey>
Recover a PrivateKey
from this Mnemonic
.
§Errors
Under certain circumstances, this function will return a Error::MnemonicEntropy
.
MnemonicEntropyError::ChecksumMismatch
if the computed checksum doesn’t match the actual checksum.MnemonicEntropyError::BadLength
if this is a v2 legacy mnemonic and doesn’t have24
words.
sourcepub fn to_private_key(&self, passphrase: &str) -> Result<PrivateKey>
pub fn to_private_key(&self, passphrase: &str) -> Result<PrivateKey>
Recover a PrivateKey
from this Mnemonic
.
§Errors
Under certain circumstances, this function will return a Error::MnemonicEntropy
.
MnemonicEntropyError::LegacyWithPassphrase
if this is a legacy private key, and the passphrase isn’t empty.MnemonicEntropyError::ChecksumMismatch
if this is a legacy private key, and theMnemonic
’s checksum doesn’t match up with the computed one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mnemonic
impl RefUnwindSafe for Mnemonic
impl Send for Mnemonic
impl Sync for Mnemonic
impl Unpin for Mnemonic
impl UnwindSafe for Mnemonic
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request