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

Show 25 methods // Required methods fn chain_height(&self) -> Result<Option<BlockHeight>, Self::Error>; fn block_metadata( &self, height: BlockHeight ) -> Result<Option<BlockMetadata>, Self::Error>; fn block_fully_scanned(&self) -> Result<Option<BlockMetadata>, Self::Error>; fn block_max_scanned(&self) -> Result<Option<BlockMetadata>, Self::Error>; fn suggest_scan_ranges(&self) -> Result<Vec<ScanRange>, Self::Error>; fn get_target_and_anchor_heights( &self, min_confirmations: NonZeroU32 ) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>; fn get_min_unspent_height(&self) -> Result<Option<BlockHeight>, Self::Error>; fn get_block_hash( &self, block_height: BlockHeight ) -> Result<Option<BlockHash>, Self::Error>; fn get_max_height_hash( &self ) -> Result<Option<(BlockHeight, BlockHash)>, Self::Error>; fn get_tx_height( &self, txid: TxId ) -> Result<Option<BlockHeight>, Self::Error>; fn get_wallet_birthday(&self) -> Result<Option<BlockHeight>, Self::Error>; fn get_account_birthday( &self, account: AccountId ) -> Result<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_wallet_summary( &self, min_confirmations: u32 ) -> Result<Option<WalletSummary>, Self::Error>; fn get_memo(&self, note_id: NoteId) -> Result<Option<Memo>, Self::Error>; fn get_transaction(&self, txid: TxId) -> Result<Transaction, Self::Error>; fn get_sapling_nullifiers( &self, query: NullifierQuery ) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>; fn get_spendable_sapling_notes( &self, account: AccountId, anchor_height: BlockHeight, exclude: &[Self::NoteRef] ) -> Result<Vec<ReceivedSaplingNote<Self::NoteRef>>, Self::Error>; fn select_spendable_sapling_notes( &self, account: AccountId, target_value: Amount, anchor_height: BlockHeight, exclude: &[Self::NoteRef] ) -> Result<Vec<ReceivedSaplingNote<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>;
}
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.

Required Methods§

source

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

Returns the height of the chain as known to the wallet as of the most recent call to WalletWrite::update_chain_tip.

This will return Ok(None) if the height of the current consensus chain tip is unknown.

source

fn block_metadata( &self, height: BlockHeight ) -> Result<Option<BlockMetadata>, Self::Error>

Returns the available block metadata for the block at the specified height, if any.

source

fn block_fully_scanned(&self) -> Result<Option<BlockMetadata>, Self::Error>

Returns the metadata for the block at the height to which the wallet has been fully scanned.

This is the height for which the wallet has fully trial-decrypted this and all preceding blocks above the wallet’s birthday height. Along with this height, this method returns metadata describing the state of the wallet’s note commitment trees as of the end of that block.

source

fn block_max_scanned(&self) -> Result<Option<BlockMetadata>, Self::Error>

Returns block metadata for the maximum height that the wallet has scanned.

If the wallet is fully synced, this will be equivalent to block_fully_scanned; otherwise the maximal scanned height is likely to be greater than the fully scanned height due to the fact that out-of-order scanning can leave gaps.

source

fn suggest_scan_ranges(&self) -> Result<Vec<ScanRange>, Self::Error>

Returns a vector of suggested scan ranges based upon the current wallet state.

This method should only be used in cases where the CompactBlock data that will be made available to scan_cached_blocks for the requested block ranges includes note commitment tree size information for each block; or else the scan is likely to fail if notes belonging to the wallet are detected.

The returned range(s) may include block heights beyond the current chain tip.

source

fn get_target_and_anchor_heights( &self, min_confirmations: NonZeroU32 ) -> 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_min_unspent_height(&self) -> Result<Option<BlockHeight>, Self::Error>

Returns the minimum block height corresponding to an unspent note in the wallet.

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_max_height_hash( &self ) -> Result<Option<(BlockHeight, BlockHash)>, Self::Error>

Returns the block height and hash for the block at the maximum scanned block height.

This will return Ok(None) if no blocks have been scanned.

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 in the main chain.

source

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

Returns the birthday height for the wallet.

This returns the earliest birthday height among accounts maintained by this wallet, or Ok(None) if the wallet has no initialized accounts.

source

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

Returns the birthday height for the given account, or an error if the account is not known to the wallet.

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_wallet_summary( &self, min_confirmations: u32 ) -> Result<Option<WalletSummary>, Self::Error>

Returns the wallet balances and sync status for an account given the specified minimum number of confirmations, or Ok(None) if the wallet has no balance data available.

source

fn get_memo(&self, note_id: NoteId) -> Result<Option<Memo>, Self::Error>

Returns the memo for a note.

Returns Ok(None) if the note is known to the wallet but memo data has not yet been populated for that note, or if the note identifier does not correspond to a note that is known to the wallet.

source

fn get_transaction(&self, txid: TxId) -> Result<Transaction, Self::Error>

Returns a transaction.

source

fn get_sapling_nullifiers( &self, query: NullifierQuery ) -> 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 a spending transaction known to the wallet has not yet been included in a block).

source

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

Return all unspent Sapling notes, excluding the specified note IDs.

source

fn select_spendable_sapling_notes( &self, account: AccountId, target_value: Amount, anchor_height: BlockHeight, exclude: &[Self::NoteRef] ) -> Result<Vec<ReceivedSaplingNote<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.

Implementors§