pub struct WalletLibrary { /* private fields */ }
Expand description

Default imports WalletLibrary contains all the information needed to recreate a particular wallet

Implementations§

source§

impl WalletLibrary

source

pub fn new() -> Self

Constructor that generates a Mnemonic from OS randomness and subsequently instantiates an empty WalletLibrary from that Mnemonic

source

pub fn new_from_mnemonic(mnemonic: Mnemonic) -> Self

Constructor that instantiates a new WalletLibrary from Mnemonic

source

pub fn mnemonic(&self) -> String

Function that returns the string representation of the WalletLibrary Mnemonic NOTE: This is not secure, and in general the mnemonic should be stored in encrypted format

source

pub fn write_recovery(&self, output_file_path: &Path) -> Result<()>

Function that writes the wallet Mnemonic to file NOTE: This is not secure, and in general the Mnemonic would need to be decrypted before it can be written to file; otherwise the encrypted Mnemonic should be written to file

source

pub fn recover(input_file_path: &Path) -> Result<WalletLibrary>

Recover wallet from input_file_path

source

pub fn key_leaf(&self) -> u64

Get the current ChildNumber in u64 format

source

pub fn generate_addresses(&mut self, depth: u64) -> Result<()>

Function that iterates from the current key_leaf until the supplied depth

source

pub fn new_address_at_child_number( &mut self, child_number: ChildNumber ) -> Result<AccountAddress>

Function that allows to get the address of a particular key at a certain ChildNumber

source

pub fn new_address(&mut self) -> Result<(AuthenticationKey, ChildNumber)>

Function that generates a new key and adds it to the addr_map and subsequently returns the AuthenticationKey associated to the PrivateKey, along with it’s ChildNumber

source

pub fn get_addresses(&self) -> Result<Vec<AccountAddress>>

Returns a list of all addresses controlled by this wallet that are currently held by the addr_map

source

pub fn sign_txn(&self, txn: RawTransaction) -> Result<SignedTransaction>

Simple public function that allows to sign a Diem RawTransaction with the PrivateKey associated to a particular AccountAddress. If the PrivateKey associated to an AccountAddress is not contained in the addr_map, then this function will return an Error

source

pub fn get_private_key( &self, address: &AccountAddress ) -> Result<Ed25519PrivateKey>

Return private key for an address in the wallet

source

pub fn get_authentication_key( &self, address: &AccountAddress ) -> Result<AuthenticationKey>

Return authentication key (AuthenticationKey) for an address in the wallet

Trait Implementations§

source§

impl TransactionSigner for WalletLibrary

WalletLibrary naturally support TransactionSigner trait.

source§

fn sign_txn(&self, raw_txn: RawTransaction) -> Result<SignedTransaction, Error>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V