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§

source

type UtxoRef

The type of identifiers used to look up transparent UTXOs.

Required Methods§

source

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).

source

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.

source

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.

source

fn store_decrypted_tx(
    &mut self,
    received_tx: &DecryptedTransaction<'_>
) -> Result<Self::TxRef, Self::Error>

Caches a decrypted transaction in the persistent wallet store.

source

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.

source

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.

source

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.

Implementors§