Trait zcash_client_backend::data_api::WalletWrite
source · pub trait WalletWrite: WalletRead {
type UtxoRef;
fn create_account(
&mut self,
seed: &SecretVec<u8>
) -> Result<(AccountId, UnifiedSpendingKey), Self::Error>;
fn get_next_available_address(
&mut self,
account: AccountId
) -> Result<Option<UnifiedAddress>, Self::Error>;
fn advance_by_block(
&mut self,
block: &PrunedBlock<'_>,
updated_witnesses: &[(Self::NoteRef, IncrementalWitness<Node>)]
) -> Result<Vec<(Self::NoteRef, IncrementalWitness<Node>)>, Self::Error>;
fn store_decrypted_tx(
&mut self,
received_tx: &DecryptedTransaction<'_>
) -> Result<Self::TxRef, Self::Error>;
fn store_sent_tx(
&mut self,
sent_tx: &SentTransaction<'_>
) -> Result<Self::TxRef, Self::Error>;
fn rewind_to_height(
&mut self,
block_height: BlockHeight
) -> Result<(), Self::Error>;
fn put_received_transparent_utxo(
&mut self,
output: &WalletTransparentOutput
) -> Result<Self::UtxoRef, Self::Error>;
}
Expand description
This trait encapsulates the write capabilities required to update stored wallet data.
Required Associated Types§
Required Methods§
sourcefn create_account(
&mut self,
seed: &SecretVec<u8>
) -> Result<(AccountId, UnifiedSpendingKey), Self::Error>
fn create_account(
&mut self,
seed: &SecretVec<u8>
) -> Result<(AccountId, UnifiedSpendingKey), Self::Error>
Tells the wallet to track the next available account-level spend authority, given the current set of ZIP 316 account identifiers known to the wallet database.
Returns the account identifier for the newly-created wallet database entry, along
with the associated [UnifiedSpendingKey
].
If seed
was imported from a backup and this method is being used to restore a
previous wallet state, you should use this method to add all of the desired
accounts before scanning the chain from the seed’s birthday height.
By convention, wallets should only allow a new account to be generated after funds have been received by the currently-available account (in order to enable automated account recovery).
sourcefn get_next_available_address(
&mut self,
account: AccountId
) -> Result<Option<UnifiedAddress>, Self::Error>
fn get_next_available_address(
&mut self,
account: AccountId
) -> Result<Option<UnifiedAddress>, Self::Error>
Generates and persists the next available diversified address, given the current addresses known to the wallet.
Returns Ok(None)
if the account identifier does not correspond to a known
account.
sourcefn advance_by_block(
&mut self,
block: &PrunedBlock<'_>,
updated_witnesses: &[(Self::NoteRef, IncrementalWitness<Node>)]
) -> Result<Vec<(Self::NoteRef, IncrementalWitness<Node>)>, Self::Error>
fn advance_by_block(
&mut self,
block: &PrunedBlock<'_>,
updated_witnesses: &[(Self::NoteRef, IncrementalWitness<Node>)]
) -> Result<Vec<(Self::NoteRef, IncrementalWitness<Node>)>, Self::Error>
Updates the state of the wallet database by persisting the provided block information, along with the updated witness data that was produced when scanning the block for transactions pertaining to this wallet.
sourcefn store_decrypted_tx(
&mut self,
received_tx: &DecryptedTransaction<'_>
) -> Result<Self::TxRef, Self::Error>
fn store_decrypted_tx(
&mut self,
received_tx: &DecryptedTransaction<'_>
) -> Result<Self::TxRef, Self::Error>
Caches a decrypted transaction in the persistent wallet store.
sourcefn store_sent_tx(
&mut self,
sent_tx: &SentTransaction<'_>
) -> Result<Self::TxRef, Self::Error>
fn store_sent_tx(
&mut self,
sent_tx: &SentTransaction<'_>
) -> Result<Self::TxRef, Self::Error>
Saves information about a transaction that was constructed and sent by the wallet to the persistent wallet store.
sourcefn rewind_to_height(
&mut self,
block_height: BlockHeight
) -> Result<(), Self::Error>
fn rewind_to_height(
&mut self,
block_height: BlockHeight
) -> Result<(), Self::Error>
Rewinds the wallet database to the specified height.
This method assumes that the state of the underlying data store is consistent up to a particular block height. Since it is possible that a chain reorg might invalidate some stored state, this method must be implemented in order to allow users of this API to “reset” the data store to correctly represent chainstate as of a specified block height.
After calling this method, the block at the given height will be the most recent block and all other operations will treat this block as the chain tip for balance determination purposes.
There may be restrictions on how far it is possible to rewind.
sourcefn put_received_transparent_utxo(
&mut self,
output: &WalletTransparentOutput
) -> Result<Self::UtxoRef, Self::Error>
fn put_received_transparent_utxo(
&mut self,
output: &WalletTransparentOutput
) -> Result<Self::UtxoRef, Self::Error>
Adds a transparent UTXO received by the wallet to the data store.