pub trait WalletRead {
    type Error;
    type NoteRef: Copy + Debug + Eq + Ord;
    type TxRef: Copy + Debug + Eq + Ord;

Show 21 methods fn block_height_extrema(
        &self
    ) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>; fn get_block_hash(
        &self,
        block_height: BlockHeight
    ) -> Result<Option<BlockHash>, Self::Error>; fn get_tx_height(
        &self,
        txid: TxId
    ) -> Result<Option<BlockHeight>, Self::Error>; fn get_current_address(
        &self,
        account: AccountId
    ) -> Result<Option<UnifiedAddress>, Self::Error>; fn get_unified_full_viewing_keys(
        &self
    ) -> Result<HashMap<AccountId, UnifiedFullViewingKey>, Self::Error>; fn get_account_for_ufvk(
        &self,
        ufvk: &UnifiedFullViewingKey
    ) -> Result<Option<AccountId>, Self::Error>; fn is_valid_account_extfvk(
        &self,
        account: AccountId,
        extfvk: &ExtendedFullViewingKey
    ) -> Result<bool, Self::Error>; fn get_balance_at(
        &self,
        account: AccountId,
        anchor_height: BlockHeight
    ) -> Result<Amount, Self::Error>; fn get_memo(&self, id_note: Self::NoteRef) -> Result<Memo, Self::Error>; fn get_transaction(
        &self,
        id_tx: Self::TxRef
    ) -> Result<Transaction, Self::Error>; fn get_commitment_tree(
        &self,
        block_height: BlockHeight
    ) -> Result<Option<CommitmentTree<Node>>, Self::Error>; fn get_witnesses(
        &self,
        block_height: BlockHeight
    ) -> Result<Vec<(Self::NoteRef, IncrementalWitness<Node>)>, Self::Error>; fn get_nullifiers(&self) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>; fn get_all_nullifiers(
        &self
    ) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>; fn get_spendable_sapling_notes(
        &self,
        account: AccountId,
        anchor_height: BlockHeight,
        exclude: &[Self::NoteRef]
    ) -> Result<Vec<SpendableNote<Self::NoteRef>>, Self::Error>; fn select_spendable_sapling_notes(
        &self,
        account: AccountId,
        target_value: Amount,
        anchor_height: BlockHeight,
        exclude: &[Self::NoteRef]
    ) -> Result<Vec<SpendableNote<Self::NoteRef>>, Self::Error>; fn get_transparent_receivers(
        &self,
        account: AccountId
    ) -> Result<HashMap<TransparentAddress, AddressMetadata>, Self::Error>; fn get_unspent_transparent_outputs(
        &self,
        address: &TransparentAddress,
        max_height: BlockHeight,
        exclude: &[OutPoint]
    ) -> Result<Vec<WalletTransparentOutput>, Self::Error>; fn get_transparent_balances(
        &self,
        account: AccountId,
        max_height: BlockHeight
    ) -> Result<HashMap<TransparentAddress, Amount>, Self::Error>; fn get_target_and_anchor_heights(
        &self,
        min_confirmations: u32
    ) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error> { ... } fn get_max_height_hash(
        &self
    ) -> Result<Option<(BlockHeight, BlockHash)>, Self::Error> { ... }
}
Expand description

Read-only operations required for light wallet functions.

This trait defines the read-only portion of the storage interface atop which higher-level wallet operations are implemented. It serves to allow wallet functions to be abstracted away from any particular data storage substrate.

Required Associated Types§

source

type Error

The type of errors produced by a wallet backend.

source

type NoteRef: Copy + Debug + Eq + Ord

Backend-specific note identifier.

For example, this might be a database identifier type or a UUID.

source

type TxRef: Copy + Debug + Eq + Ord

Backend-specific transaction identifier.

For example, this might be a database identifier type or a TxId if the backend is able to support that type directly.

Required Methods§

source

fn block_height_extrema(
    &self
) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>

Returns the minimum and maximum block heights for stored blocks.

This will return Ok(None) if no block data is present in the database.

source

fn get_block_hash(
    &self,
    block_height: BlockHeight
) -> Result<Option<BlockHash>, Self::Error>

Returns the block hash for the block at the given height, if the associated block data is available. Returns Ok(None) if the hash is not found in the database.

source

fn get_tx_height(&self, txid: TxId) -> Result<Option<BlockHeight>, Self::Error>

Returns the block height in which the specified transaction was mined, or Ok(None) if the transaction is not mined in the main chain.

source

fn get_current_address(
    &self,
    account: AccountId
) -> Result<Option<UnifiedAddress>, Self::Error>

Returns the most recently generated unified address for the specified account, if the account identifier specified refers to a valid account for this wallet.

This will return Ok(None) if the account identifier does not correspond to a known account.

source

fn get_unified_full_viewing_keys(
    &self
) -> Result<HashMap<AccountId, UnifiedFullViewingKey>, Self::Error>

Returns all unified full viewing keys known to this wallet.

source

fn get_account_for_ufvk(
    &self,
    ufvk: &UnifiedFullViewingKey
) -> Result<Option<AccountId>, Self::Error>

Returns the account id corresponding to a given [UnifiedFullViewingKey], if any.

source

fn is_valid_account_extfvk(
    &self,
    account: AccountId,
    extfvk: &ExtendedFullViewingKey
) -> Result<bool, Self::Error>

Checks whether the specified extended full viewing key is associated with the account.

source

fn get_balance_at(
    &self,
    account: AccountId,
    anchor_height: BlockHeight
) -> Result<Amount, Self::Error>

Returns the wallet balance for an account as of the specified block height.

This may be used to obtain a balance that ignores notes that have been received so recently that they are not yet deemed spendable.

source

fn get_memo(&self, id_note: Self::NoteRef) -> Result<Memo, Self::Error>

Returns the memo for a note.

Implementations of this method must return an error if the note identifier does not appear in the backing data store.

source

fn get_transaction(&self, id_tx: Self::TxRef) -> Result<Transaction, Self::Error>

Returns a transaction.

source

fn get_commitment_tree(
    &self,
    block_height: BlockHeight
) -> Result<Option<CommitmentTree<Node>>, Self::Error>

Returns the note commitment tree at the specified block height.

source

fn get_witnesses(
    &self,
    block_height: BlockHeight
) -> Result<Vec<(Self::NoteRef, IncrementalWitness<Node>)>, Self::Error>

Returns the incremental witnesses as of the specified block height.

source

fn get_nullifiers(&self) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>

Returns the nullifiers for notes that the wallet is tracking, along with their associated account IDs, that are either unspent or have not yet been confirmed as spent (in that the spending transaction has not yet been included in a block).

source

fn get_all_nullifiers(&self) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>

Returns all nullifiers for notes that the wallet is tracking (including those for notes that have been previously spent), along with the account identifiers with which they are associated.

source

fn get_spendable_sapling_notes(
    &self,
    account: AccountId,
    anchor_height: BlockHeight,
    exclude: &[Self::NoteRef]
) -> Result<Vec<SpendableNote<Self::NoteRef>>, Self::Error>

Return all unspent Sapling notes.

source

fn select_spendable_sapling_notes(
    &self,
    account: AccountId,
    target_value: Amount,
    anchor_height: BlockHeight,
    exclude: &[Self::NoteRef]
) -> Result<Vec<SpendableNote<Self::NoteRef>>, Self::Error>

Returns a list of spendable Sapling notes sufficient to cover the specified target value, if possible.

source

fn get_transparent_receivers(
    &self,
    account: AccountId
) -> Result<HashMap<TransparentAddress, AddressMetadata>, Self::Error>

Returns the set of all transparent receivers associated with the given account.

The set contains all transparent receivers that are known to have been derived under this account. Wallets should scan the chain for UTXOs sent to these receivers.

source

fn get_unspent_transparent_outputs(
    &self,
    address: &TransparentAddress,
    max_height: BlockHeight,
    exclude: &[OutPoint]
) -> Result<Vec<WalletTransparentOutput>, Self::Error>

Returns a list of unspent transparent UTXOs that appear in the chain at heights up to and including max_height.

source

fn get_transparent_balances(
    &self,
    account: AccountId,
    max_height: BlockHeight
) -> Result<HashMap<TransparentAddress, Amount>, Self::Error>

Returns a mapping from transparent receiver to not-yet-shielded UTXO balance, for each address associated with a nonzero balance.

Provided Methods§

source

fn get_target_and_anchor_heights(
    &self,
    min_confirmations: u32
) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>

Returns the default target height (for the block in which a new transaction would be mined) and anchor height (to use for a new transaction), given the range of block heights that the backend knows about.

This will return Ok(None) if no block data is present in the database.

source

fn get_max_height_hash(
    &self
) -> Result<Option<(BlockHeight, BlockHash)>, Self::Error>

Returns the block hash for the block at the maximum height known in stored data.

This will return Ok(None) if no block data is present in the database.

Implementors§