Struct diem_wallet::WalletLibrary
source · pub struct WalletLibrary { /* private fields */ }
Expand description
Default imports WalletLibrary contains all the information needed to recreate a particular wallet
Implementations§
source§impl WalletLibrary
impl WalletLibrary
sourcepub fn new() -> Self
pub fn new() -> Self
Constructor that generates a Mnemonic from OS randomness and subsequently instantiates an empty WalletLibrary from that Mnemonic
sourcepub fn new_from_mnemonic(mnemonic: Mnemonic) -> Self
pub fn new_from_mnemonic(mnemonic: Mnemonic) -> Self
Constructor that instantiates a new WalletLibrary from Mnemonic
sourcepub fn mnemonic(&self) -> String
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
sourcepub fn write_recovery(&self, output_file_path: &Path) -> Result<()>
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
sourcepub fn recover(input_file_path: &Path) -> Result<WalletLibrary>
pub fn recover(input_file_path: &Path) -> Result<WalletLibrary>
Recover wallet from input_file_path
sourcepub fn generate_addresses(&mut self, depth: u64) -> Result<()>
pub fn generate_addresses(&mut self, depth: u64) -> Result<()>
Function that iterates from the current key_leaf until the supplied depth
sourcepub fn new_address_at_child_number(
&mut self,
child_number: ChildNumber
) -> Result<AccountAddress>
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
sourcepub fn new_address(&mut self) -> Result<(AuthenticationKey, ChildNumber)>
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
sourcepub fn get_addresses(&self) -> Result<Vec<AccountAddress>>
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
sourcepub fn sign_txn(&self, txn: RawTransaction) -> Result<SignedTransaction>
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
sourcepub fn get_private_key(
&self,
address: &AccountAddress
) -> Result<Ed25519PrivateKey>
pub fn get_private_key( &self, address: &AccountAddress ) -> Result<Ed25519PrivateKey>
Return private key for an address in the wallet
sourcepub fn get_authentication_key(
&self,
address: &AccountAddress
) -> Result<AuthenticationKey>
pub fn get_authentication_key( &self, address: &AccountAddress ) -> Result<AuthenticationKey>
Return authentication key (AuthenticationKey) for an address in the wallet