Trait grin_wallet_libwallet::WalletBackend
source · pub trait WalletBackend<'ck, C, K>: Send + Syncwhere
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§
sourcefn set_keychain(
&mut self,
k: Box<K>,
mask: bool,
use_test_rng: bool
) -> Result<Option<SecretKey>, Error>
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
sourcefn keychain(&self, mask: Option<&SecretKey>) -> Result<K, Error>
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
sourcefn w2n_client(&mut self) -> &mut C
fn w2n_client(&mut self) -> &mut C
Return the client being used to communicate with the node
sourcefn calc_commit_for_cache(
&mut self,
keychain_mask: Option<&SecretKey>,
amount: u64,
id: &Identifier
) -> Result<Option<String>, Error>
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
sourcefn set_parent_key_id_by_name(&mut self, label: &str) -> Result<(), Error>
fn set_parent_key_id_by_name(&mut self, label: &str) -> Result<(), Error>
Set parent key id by stored account name
sourcefn set_parent_key_id(&mut self, _: Identifier)
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.
sourcefn parent_key_id(&mut self) -> Identifier
fn parent_key_id(&mut self) -> Identifier
return the parent path
sourcefn iter<'a>(&'a self) -> Box<dyn Iterator<Item = OutputData> + 'a>
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = OutputData> + 'a>
Iterate over all output data stored by the backend
sourcefn get(
&self,
id: &Identifier,
mmr_index: &Option<u64>
) -> Result<OutputData, Error>
fn get( &self, id: &Identifier, mmr_index: &Option<u64> ) -> Result<OutputData, Error>
Get output data by id
sourcefn get_tx_log_entry(&self, uuid: &Uuid) -> Result<Option<TxLogEntry>, Error>
fn get_tx_log_entry(&self, uuid: &Uuid) -> Result<Option<TxLogEntry>, Error>
Get an (Optional) tx log entry by uuid
sourcefn get_private_context(
&mut self,
keychain_mask: Option<&SecretKey>,
slate_id: &[u8]
) -> Result<Context, Error>
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
sourcefn tx_log_iter<'a>(&'a self) -> Box<dyn Iterator<Item = TxLogEntry> + 'a>
fn tx_log_iter<'a>(&'a self) -> Box<dyn Iterator<Item = TxLogEntry> + 'a>
Iterate over all output data stored by the backend
sourcefn acct_path_iter<'a>(
&'a self
) -> Box<dyn Iterator<Item = AcctPathMapping> + 'a>
fn acct_path_iter<'a>( &'a self ) -> Box<dyn Iterator<Item = AcctPathMapping> + 'a>
Iterate over all stored account paths
sourcefn get_acct_path(&self, label: String) -> Result<Option<AcctPathMapping>, Error>
fn get_acct_path(&self, label: String) -> Result<Option<AcctPathMapping>, Error>
Gets an account path for a given label
sourcefn get_stored_tx(&self, uuid: &str) -> Result<Option<Transaction>, Error>
fn get_stored_tx(&self, uuid: &str) -> Result<Option<Transaction>, Error>
Retrieves a stored transaction from a TxLogEntry
sourcefn batch<'a>(
&'a mut self,
keychain_mask: Option<&SecretKey>
) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>
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
sourcefn batch_no_mask<'a>(
&'a mut self
) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>
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
sourcefn current_child_index(
&mut self,
parent_key_id: &Identifier
) -> Result<u32, Error>
fn current_child_index( &mut self, parent_key_id: &Identifier ) -> Result<u32, Error>
Return the current child Index
sourcefn next_child(
&mut self,
keychain_mask: Option<&SecretKey>
) -> Result<Identifier, Error>
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
sourcefn last_confirmed_height(&mut self) -> Result<u64, Error>
fn last_confirmed_height(&mut self) -> Result<u64, Error>
last verified height of outputs directly descending from the given parent key
sourcefn last_scanned_block(&mut self) -> Result<ScannedBlockInfo, Error>
fn last_scanned_block(&mut self) -> Result<ScannedBlockInfo, Error>
last block scanned during scan or restore
sourcefn init_status(&mut self) -> Result<WalletInitStatus, Error>
fn init_status(&mut self) -> Result<WalletInitStatus, Error>
Flag whether the wallet needs a full UTXO scan on next update attempt