[][src]Trait grin_wallet_libwallet::WalletBackend

pub trait WalletBackend<C, K> where
    C: NodeClient,
    K: Keychain, 
{ fn open_with_credentials(&mut self) -> Result<(), Error>;
fn close(&mut self) -> Result<(), Error>;
fn keychain(&mut self) -> &mut K;
fn w2n_client(&mut self) -> &mut C;
fn calc_commit_for_cache(
        &mut self,
        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,
        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
    ) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>;
fn next_child<'a>(&mut self) -> Result<Identifier, Error>;
fn last_confirmed_height<'a>(&mut self) -> Result<u64, Error>;
fn restore(&mut self) -> Result<(), Error>;
fn check_repair(&mut self, delete_unconfirmed: bool) -> Result<(), 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 open_with_credentials(&mut self) -> Result<(), Error>

Initialize with whatever stored credentials we have

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

Close wallet and remove any stored credentials (TBD)

fn keychain(&mut self) -> &mut K

Return the keychain being used

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

Return the client being used to communicate with the node

fn calc_commit_for_cache(
    &mut self,
    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,
    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) -> Result<Box<dyn WalletOutputBatch<K> + 'a>, Error>

Create a new write batch to update or remove output data

fn next_child<'a>(&mut self) -> Result<Identifier, Error>

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

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

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

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

Attempt to restore the contents of a wallet from seed

fn check_repair(&mut self, delete_unconfirmed: bool) -> Result<(), Error>

Attempt to check and fix wallet state

Loading content...

Implementors

Loading content...