[][src]Trait grin_wallet_libwallet::WalletBackend

pub trait WalletBackend<'ck, C, K>: Send + Sync where
    C: NodeClient + 'ck,
    K: Keychain + 'ck, 
{ 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],
        participant_id: usize
    ) -> 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,
        entry: &TxLogEntry
    ) -> 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>; }

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

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

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

Close wallet and remove any stored credentials (TBD)

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

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

Return the client being used to communicate with the node

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

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

Set parent key id by stored account name

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.

fn parent_key_id(&mut self) -> Identifier

return the parent path

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

Iterate over all output data stored by the backend

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

Get output data by id

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

Get an (Optional) tx log entry by uuid

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

Retrieves the private context associated with a given slate id

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

Iterate over all output data stored by the backend

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

Iterate over all stored account paths

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

Gets an account path for a given label

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

Stores a transaction

fn get_stored_tx(
    &self,
    entry: &TxLogEntry
) -> Result<Option<Transaction>, Error>

Retrieves a stored transaction from a TxLogEntry

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

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

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

Return the current child Index

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

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

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

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

last block scanned during scan or restore

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

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

Loading content...

Implementors

Loading content...