Skip to main content

Wallet

Struct Wallet 

Source
pub struct Wallet { /* private fields */ }
Expand description

A unified HD wallet that can derive keys for multiple cryptocurrencies.

This wallet holds a BIP39 mnemonic and derives a seed that can be used to generate addresses for Bitcoin, Ethereum, and other coins following BIP32/44/49/84 standards.

§Passphrase Support

The wallet supports an optional BIP39 passphrase (sometimes called “25th word”). This provides an extra layer of security - the same mnemonic with different passphrases will produce completely different wallets.

Implementations§

Source§

impl Wallet

Source

pub fn generate( word_count: usize, passphrase: Option<&str>, ) -> Result<Self, Error>

Generate a new wallet with a random mnemonic.

§Arguments
  • word_count - Number of words (12, 15, 18, 21, or 24)
  • passphrase - Optional BIP39 passphrase for additional security
§Errors

Returns an error if the word count is invalid.

Source

pub fn from_mnemonic( phrase: &str, passphrase: Option<&str>, ) -> Result<Self, Error>

Create a wallet from an existing mnemonic phrase.

§Arguments
  • phrase - BIP39 mnemonic phrase
  • passphrase - Optional BIP39 passphrase
§Errors

Returns an error if the mnemonic is invalid.

Source

pub fn mnemonic(&self) -> &str

Get the mnemonic phrase.

Security Warning: Handle this value carefully as it can reconstruct all derived keys.

Source

pub fn seed(&self) -> &[u8; 64]

Get the seed bytes for key derivation.

This seed can be used by chain-specific derivers (Bitcoin, Ethereum, etc.) to generate addresses following their respective standards.

Source

pub const fn has_passphrase(&self) -> bool

Check if a passphrase was used to derive the seed.

Source

pub fn word_count(&self) -> usize

Get the word count of the mnemonic.

Trait Implementations§

Source§

impl Debug for Wallet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Wallet

§

impl RefUnwindSafe for Wallet

§

impl Send for Wallet

§

impl Sync for Wallet

§

impl Unpin for Wallet

§

impl UnwindSafe for Wallet

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V