Struct coins_bip39::mnemonic::Mnemonic
source · [−]pub struct Mnemonic<W: Wordlist> { /* private fields */ }
Expand description
Mnemonic represents entropy that can be represented as a phrase. A mnemonic can be used to deterministically generate an extended private key or derive its child keys.
Implementations
sourceimpl<W: Wordlist> Mnemonic<W>
impl<W: Wordlist> Mnemonic<W>
sourcepub fn new<R: Rng>(rng: &mut R) -> Self
pub fn new<R: Rng>(rng: &mut R) -> Self
Returns a new mnemonic generated using the provided random number generator.
sourcepub fn new_with_count<R: Rng>(
rng: &mut R,
count: usize
) -> Result<Self, MnemonicError>
pub fn new_with_count<R: Rng>(
rng: &mut R,
count: usize
) -> Result<Self, MnemonicError>
Returns a new mnemonic given the word count, generated using the provided random number generator.
sourcepub fn new_from_phrase(phrase: &str) -> Result<Self, MnemonicError>
pub fn new_from_phrase(phrase: &str) -> Result<Self, MnemonicError>
Returns a new mnemonic for a given phrase. The 12-24 space-separated words are used to calculate the entropy that must have produced it.
sourcepub fn to_phrase(&self) -> Result<String, MnemonicError>
pub fn to_phrase(&self) -> Result<String, MnemonicError>
Converts the mnemonic into phrase.
sourceimpl<W: Wordlist> Mnemonic<W>
impl<W: Wordlist> Mnemonic<W>
sourcepub fn master_key(&self, password: Option<&str>) -> Result<XPriv, MnemonicError>
pub fn master_key(&self, password: Option<&str>) -> Result<XPriv, MnemonicError>
Returns the master private key of the corresponding mnemonic.
sourcepub fn derive_key<E, P>(
&self,
path: P,
password: Option<&str>
) -> Result<XPriv, MnemonicError> where
E: Into<Bip32Error>,
P: TryInto<DerivationPath, Error = E>,
pub fn derive_key<E, P>(
&self,
path: P,
password: Option<&str>
) -> Result<XPriv, MnemonicError> where
E: Into<Bip32Error>,
P: TryInto<DerivationPath, Error = E>,
Returns the derived child private key of the corresponding mnemonic at the given index.
Trait Implementations
impl<W: Eq + Wordlist> Eq for Mnemonic<W>
impl<W: Wordlist> StructuralEq for Mnemonic<W>
impl<W: Wordlist> StructuralPartialEq for Mnemonic<W>
Auto Trait Implementations
impl<W> RefUnwindSafe for Mnemonic<W> where
W: RefUnwindSafe,
impl<W> Send for Mnemonic<W> where
W: Send,
impl<W> Sync for Mnemonic<W> where
W: Sync,
impl<W> Unpin for Mnemonic<W> where
W: Unpin,
impl<W> UnwindSafe for Mnemonic<W> where
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more