Trait grin_wallet_libwallet::WalletBackend

source ·
pub trait WalletBackend<'ck, C, K>: Send + Sync
where C: NodeClient + 'ck, K: Keychain + 'ck,
{
Show 24 methods // Required methods fn set_keychain( &mut self, k: Box<K>, mask: bool, use_test_rng: bool ) -> Result<Option<SecretKey>, Error>; fn close(&mut self) -> Result<(), Error>; fn keychain(&self, mask: Option<&SecretKey>) -> Result<K, Error>; fn w2n_client(&mut self) -> &mut C; fn calc_commit_for_cache( &mut self, keychain_mask: Option<&SecretKey>, amount: u64, id: &Identifier ) -> Result<Option<String>, Error>; fn set_parent_key_id_by_name(&mut self, label: &str) -> Result<(), Error>; fn set_parent_key_id(&mut self, _: Identifier); fn parent_key_id(&mut self) -> Identifier; fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = OutputData> + 'a>; fn get( &self, id: &Identifier, mmr_index: &Option<u64> ) -> Result<OutputData, Error>; fn get_tx_log_entry(&self, uuid: &Uuid) -> Result<Option<TxLogEntry>, Error>; fn get_private_context( &mut self, keychain_mask: Option<&SecretKey>, slate_id: &[u8] ) -> Result<Context, Error>; fn tx_log_iter<'a>(&'a self) -> Box<dyn Iterator<Item = TxLogEntry> + 'a>; fn acct_path_iter<'a>( &'a self ) -> Box<dyn Iterator<Item = AcctPathMapping> + 'a>; fn get_acct_path( &self, label: String ) -> Result<Option<AcctPathMapping>, Error>; fn store_tx(&self, uuid: &str, tx: &Transaction) -> Result<(), Error>; fn get_stored_tx(&self, uuid: &str) -> Result<Option<Transaction>, Error>; fn batch<'a>( &'a mut self, keychain_mask: Option<&SecretKey> ) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>; fn batch_no_mask<'a>( &'a mut self ) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>; fn current_child_index( &mut self, parent_key_id: &Identifier ) -> Result<u32, Error>; fn next_child( &mut self, keychain_mask: Option<&SecretKey> ) -> Result<Identifier, Error>; fn last_confirmed_height(&mut self) -> Result<u64, Error>; fn last_scanned_block(&mut self) -> Result<ScannedBlockInfo, Error>; fn init_status(&mut self) -> Result<WalletInitStatus, Error>;
}
Expand description

TODO: Wallets should implement this backend for their storage. All functions here expect that the wallet instance has instantiated itself or stored whatever credentials it needs

Required Methods§

source

fn set_keychain( &mut self, k: Box<K>, mask: bool, use_test_rng: bool ) -> Result<Option<SecretKey>, Error>

Set the keychain, which should already be initialized Optionally return a token value used to XOR the stored key value

source

fn close(&mut self) -> Result<(), Error>

Close wallet and remove any stored credentials (TBD)

source

fn keychain(&self, mask: Option<&SecretKey>) -> Result<K, Error>

Return the keychain being used. Ensure a cloned copy so it will be dropped and zeroized by the caller Can optionally take a mask value

source

fn w2n_client(&mut self) -> &mut C

Return the client being used to communicate with the node

source

fn calc_commit_for_cache( &mut self, keychain_mask: Option<&SecretKey>, amount: u64, id: &Identifier ) -> Result<Option<String>, Error>

return the commit for caching if allowed, none otherwise

source

fn set_parent_key_id_by_name(&mut self, label: &str) -> Result<(), Error>

Set parent key id by stored account name

source

fn set_parent_key_id(&mut self, _: Identifier)

The BIP32 path of the parent path to use for all output-related functions, (essentially ‘accounts’ within a wallet.

source

fn parent_key_id(&mut self) -> Identifier

return the parent path

source

fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = OutputData> + 'a>

Iterate over all output data stored by the backend

source

fn get( &self, id: &Identifier, mmr_index: &Option<u64> ) -> Result<OutputData, Error>

Get output data by id

source

fn get_tx_log_entry(&self, uuid: &Uuid) -> Result<Option<TxLogEntry>, Error>

Get an (Optional) tx log entry by uuid

source

fn get_private_context( &mut self, keychain_mask: Option<&SecretKey>, slate_id: &[u8] ) -> Result<Context, Error>

Retrieves the private context associated with a given slate id

source

fn tx_log_iter<'a>(&'a self) -> Box<dyn Iterator<Item = TxLogEntry> + 'a>

Iterate over all output data stored by the backend

source

fn acct_path_iter<'a>( &'a self ) -> Box<dyn Iterator<Item = AcctPathMapping> + 'a>

Iterate over all stored account paths

source

fn get_acct_path(&self, label: String) -> Result<Option<AcctPathMapping>, Error>

Gets an account path for a given label

source

fn store_tx(&self, uuid: &str, tx: &Transaction) -> Result<(), Error>

Stores a transaction

source

fn get_stored_tx(&self, uuid: &str) -> Result<Option<Transaction>, Error>

Retrieves a stored transaction from a TxLogEntry

source

fn batch<'a>( &'a mut self, keychain_mask: Option<&SecretKey> ) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>

Create a new write batch to update or remove output data

source

fn batch_no_mask<'a>( &'a mut self ) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>

Batch for use when keychain isn’t available or required

source

fn current_child_index( &mut self, parent_key_id: &Identifier ) -> Result<u32, Error>

Return the current child Index

source

fn next_child( &mut self, keychain_mask: Option<&SecretKey> ) -> Result<Identifier, Error>

Next child ID when we want to create a new output, based on current parent

source

fn last_confirmed_height(&mut self) -> Result<u64, Error>

last verified height of outputs directly descending from the given parent key

source

fn last_scanned_block(&mut self) -> Result<ScannedBlockInfo, Error>

last block scanned during scan or restore

source

fn init_status(&mut self) -> Result<WalletInitStatus, Error>

Flag whether the wallet needs a full UTXO scan on next update attempt

Implementors§