Trait zcash_client_backend::data_api::WalletRead
source · 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§
Required Methods§
sourcefn block_height_extrema(
&self
) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>
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.
sourcefn get_block_hash(
&self,
block_height: BlockHeight
) -> Result<Option<BlockHash>, Self::Error>
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.
sourcefn get_tx_height(&self, txid: TxId) -> Result<Option<BlockHeight>, Self::Error>
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.
sourcefn get_current_address(
&self,
account: AccountId
) -> Result<Option<UnifiedAddress>, Self::Error>
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.
sourcefn get_unified_full_viewing_keys(
&self
) -> Result<HashMap<AccountId, UnifiedFullViewingKey>, Self::Error>
fn get_unified_full_viewing_keys(
&self
) -> Result<HashMap<AccountId, UnifiedFullViewingKey>, Self::Error>
Returns all unified full viewing keys known to this wallet.
sourcefn get_account_for_ufvk(
&self,
ufvk: &UnifiedFullViewingKey
) -> Result<Option<AccountId>, Self::Error>
fn get_account_for_ufvk(
&self,
ufvk: &UnifiedFullViewingKey
) -> Result<Option<AccountId>, Self::Error>
Returns the account id corresponding to a given [UnifiedFullViewingKey
],
if any.
sourcefn is_valid_account_extfvk(
&self,
account: AccountId,
extfvk: &ExtendedFullViewingKey
) -> Result<bool, Self::Error>
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.
sourcefn get_balance_at(
&self,
account: AccountId,
anchor_height: BlockHeight
) -> Result<Amount, Self::Error>
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.
sourcefn get_memo(&self, id_note: Self::NoteRef) -> Result<Memo, Self::Error>
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.
sourcefn get_transaction(&self, id_tx: Self::TxRef) -> Result<Transaction, Self::Error>
fn get_transaction(&self, id_tx: Self::TxRef) -> Result<Transaction, Self::Error>
Returns a transaction.
sourcefn get_commitment_tree(
&self,
block_height: BlockHeight
) -> Result<Option<CommitmentTree<Node>>, Self::Error>
fn get_commitment_tree(
&self,
block_height: BlockHeight
) -> Result<Option<CommitmentTree<Node>>, Self::Error>
Returns the note commitment tree at the specified block height.
sourcefn get_witnesses(
&self,
block_height: BlockHeight
) -> Result<Vec<(Self::NoteRef, IncrementalWitness<Node>)>, Self::Error>
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.
sourcefn get_nullifiers(&self) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>
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).
sourcefn get_all_nullifiers(&self) -> Result<Vec<(AccountId, Nullifier)>, Self::Error>
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.
sourcefn get_spendable_sapling_notes(
&self,
account: AccountId,
anchor_height: BlockHeight,
exclude: &[Self::NoteRef]
) -> Result<Vec<SpendableNote<Self::NoteRef>>, Self::Error>
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.
sourcefn select_spendable_sapling_notes(
&self,
account: AccountId,
target_value: Amount,
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>
Returns a list of spendable Sapling notes sufficient to cover the specified target value, if possible.
sourcefn get_transparent_receivers(
&self,
account: AccountId
) -> Result<HashMap<TransparentAddress, AddressMetadata>, Self::Error>
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.
sourcefn get_unspent_transparent_outputs(
&self,
address: &TransparentAddress,
max_height: BlockHeight,
exclude: &[OutPoint]
) -> Result<Vec<WalletTransparentOutput>, Self::Error>
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
.
sourcefn get_transparent_balances(
&self,
account: AccountId,
max_height: BlockHeight
) -> Result<HashMap<TransparentAddress, Amount>, Self::Error>
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§
sourcefn get_target_and_anchor_heights(
&self,
min_confirmations: u32
) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>
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.
sourcefn get_max_height_hash(
&self
) -> Result<Option<(BlockHeight, BlockHash)>, Self::Error>
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.