Trait BarkPersister

Source
pub trait BarkPersister:
    Send
    + Sync
    + 'static {
Show 50 methods // Required methods fn init_wallet<'life0, 'life1, 'async_trait>( &'life0 self, properties: &'life1 WalletProperties, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn initialize_bdk_wallet<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ChangeSet>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_bdk_wallet_changeset<'life0, 'life1, 'async_trait>( &'life0 self, changeset: &'life1 ChangeSet, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn read_properties<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<WalletProperties>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_server_pubkey<'life0, 'async_trait>( &'life0 self, server_pubkey: PublicKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_new_movement<'life0, 'life1, 'async_trait>( &'life0 self, status: MovementStatus, subsystem: &'life1 MovementSubsystem, time: DateTime<Local>, ) -> Pin<Box<dyn Future<Output = Result<MovementId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update_movement<'life0, 'life1, 'async_trait>( &'life0 self, movement: &'life1 Movement, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_movement_by_id<'life0, 'async_trait>( &'life0 self, movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<Movement>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_all_movements<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Movement>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_pending_board<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, vtxo: &'life1 Vtxo<Full>, funding_tx: &'life2 Transaction, movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn remove_pending_board<'life0, 'life1, 'async_trait>( &'life0 self, vtxo_id: &'life1 VtxoId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_all_pending_board_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<VtxoId>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_pending_board_by_vtxo_id<'life0, 'async_trait>( &'life0 self, vtxo_id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<Option<PendingBoard>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_round_state_lock_vtxos<'life0, 'life1, 'async_trait>( &'life0 self, round_state: &'life1 RoundState, ) -> Pin<Box<dyn Future<Output = Result<RoundStateId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update_round_state<'life0, 'life1, 'async_trait>( &'life0 self, round_state: &'life1 StoredRoundState, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_round_state<'life0, 'life1, 'async_trait>( &'life0 self, round_state: &'life1 StoredRoundState, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_round_state_by_id<'life0, 'async_trait>( &'life0 self, id: RoundStateId, ) -> Pin<Box<dyn Future<Output = Result<Option<StoredRoundState<Unlocked>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_pending_round_state_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<RoundStateId>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_vtxos<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, vtxos: &'life1 [(&'life2 Vtxo<Full>, &'life3 VtxoState)], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn get_wallet_vtxo<'life0, 'async_trait>( &'life0 self, id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<Option<WalletVtxo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_all_vtxos<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<WalletVtxo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_vtxos_by_state<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 [VtxoStateKind], ) -> Pin<Box<dyn Future<Output = Result<Vec<WalletVtxo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_vtxo<'life0, 'async_trait>( &'life0 self, id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<Option<Vtxo<Full>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn has_spent_vtxo<'life0, 'async_trait>( &'life0 self, id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_vtxo_key<'life0, 'async_trait>( &'life0 self, index: u32, public_key: PublicKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_last_vtxo_key_index<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_public_key_idx<'life0, 'life1, 'async_trait>( &'life0 self, public_key: &'life1 PublicKey, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_mailbox_checkpoint<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_mailbox_checkpoint<'life0, 'async_trait>( &'life0 self, checkpoint: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_new_pending_lightning_send<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, invoice: &'life1 Invoice, amount: Amount, fee: Amount, vtxos: &'life2 [VtxoId], movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<LightningSend>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_all_pending_lightning_send<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<LightningSend>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn finish_lightning_send<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, preimage: Option<Preimage>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_lightning_send<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_lightning_send<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<Option<LightningSend>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_lightning_receive<'life0, 'life1, 'async_trait>( &'life0 self, payment_hash: PaymentHash, preimage: Preimage, invoice: &'life1 Bolt11Invoice, htlc_recv_cltv_delta: BlockDelta, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_all_pending_lightning_receives<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<LightningReceive>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_preimage_revealed<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_lightning_receive<'life0, 'life1, 'async_trait>( &'life0 self, payment_hash: PaymentHash, htlc_vtxo_ids: &'life1 [VtxoId], movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn fetch_lightning_receive_by_payment_hash<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<Option<LightningReceive>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn finish_pending_lightning_receive<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_exit_vtxo_entry<'life0, 'life1, 'async_trait>( &'life0 self, exit: &'life1 StoredExit, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_exit_vtxo_entry<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 VtxoId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_exit_vtxo_entries<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredExit>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn store_exit_child_tx<'life0, 'life1, 'async_trait>( &'life0 self, exit_txid: Txid, child_tx: &'life1 Transaction, origin: ExitTxOrigin, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_exit_child_tx<'life0, 'async_trait>( &'life0 self, exit_txid: Txid, ) -> Pin<Box<dyn Future<Output = Result<Option<(Transaction, ExitTxOrigin)>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_vtxo_state_checked<'life0, 'life1, 'async_trait>( &'life0 self, vtxo_id: VtxoId, new_state: VtxoState, allowed_old_states: &'life1 [VtxoStateKind], ) -> Pin<Box<dyn Future<Output = Result<WalletVtxo>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn store_pending_offboard<'life0, 'life1, 'async_trait>( &'life0 self, pending: &'life1 PendingOffboard, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_pending_offboards<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<PendingOffboard>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_pending_offboard<'life0, 'async_trait>( &'life0 self, movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided method fn is_initialized<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

Storage interface for Bark wallets.

Implement this trait to plug a custom persistence backend. The wallet uses it to:

  • Initialize and read wallet properties and configuration.
  • Record movements (spends/receives), recipients, and enforce Vtxo state transitions.
  • Manage round lifecycles (attempts, pending confirmation, confirmations/cancellations).
  • Persist ephemeral protocol artifacts (e.g., secret nonces) transactionally.
  • Track Lightning receives and preimage revelation.
  • Track exit-related data and associated child transactions.
  • Persist the last synchronized Ark block height.

Feature integration:

  • With the onchain-bdk feature, methods are provided to initialize and persist a BDK wallet ChangeSet in the same storage.

Notes for implementors:

  • Ensure that operations that change multiple records (e.g., registering a movement, storing round state transitions) are executed transactionally.
  • Enforce state integrity by verifying allowed_old_states before updating a Vtxo state.
  • If your backend is not thread-safe, prefer a short-lived connection per call or use an internal pool with checked-out connections per operation.
  • Return precise errors so callers can surface actionable diagnostics.

Required Methods§

Source

fn init_wallet<'life0, 'life1, 'async_trait>( &'life0 self, properties: &'life1 WalletProperties, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initialize a wallet in storage with the provided properties.

Call exactly once per wallet database. Subsequent calls should fail to prevent accidental re-initialization.

Parameters:

  • properties: WalletProperties to persist (e.g., network, descriptors, metadata).

Returns:

  • Ok(()) on success.

Errors:

  • Returns an error if the wallet is already initialized or if persistence fails.
Source

fn initialize_bdk_wallet<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ChangeSet>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize the onchain BDK wallet and return any previously stored ChangeSet.

Must be called before storing any new BDK changesets to bootstrap the BDK state.

Feature: only available with onchain-bdk.

Returns:

  • Ok(ChangeSet) containing the previously persisted BDK state (possibly empty).

Errors:

  • Returns an error if the BDK state cannot be created or loaded.
Source

fn store_bdk_wallet_changeset<'life0, 'life1, 'async_trait>( &'life0 self, changeset: &'life1 ChangeSet, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist an incremental BDK ChangeSet.

The changeset should be applied atomically. Callers typically obtain the changeset from a BDK wallet instance after mutating wallet state (e.g., sync).

Feature: only available with onchain-bdk.

Parameters:

  • changeset: The BDK ChangeSet to persist.

Errors:

  • Returns an error if the changeset cannot be written.
Source

fn read_properties<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<WalletProperties>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read wallet properties from storage.

Returns:

  • Ok(Some(WalletProperties)) if the wallet has been initialized.
  • Ok(None) if no wallet exists yet.

Errors:

  • Returns an error on I/O or deserialization failures.
Source

fn set_server_pubkey<'life0, 'async_trait>( &'life0 self, server_pubkey: PublicKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the server public key in wallet properties.

This is used to store the server pubkey for existing wallets that were created before server pubkey tracking was added. Once set, the wallet will verify the server pubkey on every connection.

Parameters:

  • server_pubkey: The server’s public key to store.

Errors:

  • Returns an error if the update fails.
Source

fn create_new_movement<'life0, 'life1, 'async_trait>( &'life0 self, status: MovementStatus, subsystem: &'life1 MovementSubsystem, time: DateTime<Local>, ) -> Pin<Box<dyn Future<Output = Result<MovementId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a new movement in the given state, ready to be updated.

Parameters:

  • status: The desired status for the new movement.
  • subsystem: The subsystem that created the movement.
  • time: The time the movement should be marked as created.

Returns:

  • Ok(MovementId) of the newly created movement.

Errors:

  • Returns an error if the movement is unable to be created.
Source

fn update_movement<'life0, 'life1, 'async_trait>( &'life0 self, movement: &'life1 Movement, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persists the given movement state.

Parameters:

  • movement: The movement and its associated data to be persisted.

Errors:

  • Returns an error if updating the movement fails for any reason.
Source

fn get_movement_by_id<'life0, 'async_trait>( &'life0 self, movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<Movement>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the movement with the given MovementId.

Parameters:

  • movement_id: The ID of the movement to retrieve.

Returns:

  • Ok(Movement) if the movement exists.

Errors:

  • If the movement does not exist.
  • If retrieving the movement fails.
Source

fn get_all_movements<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Movement>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets every stored movement.

Returns:

  • Ok(Vec<Movement>) containing all movements, empty if none exist.

Errors:

  • If retrieving the movements fails.
Source

fn store_pending_board<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, vtxo: &'life1 Vtxo<Full>, funding_tx: &'life2 Transaction, movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a pending board.

Parameters:

  • vtxo: The Vtxo to store.
  • funding_txid: The funding Txid.
  • movement_id: The MovementId associated with this board.

Errors:

  • Returns an error if the board cannot be stored.
Source

fn remove_pending_board<'life0, 'life1, 'async_trait>( &'life0 self, vtxo_id: &'life1 VtxoId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a pending board.

Parameters:

  • vtxo_id: The VtxoId to remove.

Errors:

  • Returns an error if the board cannot be removed.
Source

fn get_all_pending_board_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<VtxoId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the VtxoId for each pending board.

Returns:

  • Ok(Vec<VtxoId>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn get_pending_board_by_vtxo_id<'life0, 'async_trait>( &'life0 self, vtxo_id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<Option<PendingBoard>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the PendingBoard associated with the given VtxoId.

Returns:

  • Ok(Some(PendingBoard)) if a matching board exists
  • Ok(None) if no matching board exists

Errors:

  • Returns an error if the query fails.
Source

fn store_round_state_lock_vtxos<'life0, 'life1, 'async_trait>( &'life0 self, round_state: &'life1 RoundState, ) -> Pin<Box<dyn Future<Output = Result<RoundStateId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a new ongoing round state and lock the VTXOs in round

Parameters:

  • round_state: the state to store

Returns:

  • RoundStateId: the storaged ID of the new state

Errors:

  • returns an error of the new round state could not be stored or the VTXOs couldn’t be marked as locked
Source

fn update_round_state<'life0, 'life1, 'async_trait>( &'life0 self, round_state: &'life1 StoredRoundState, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update an existing stored pending round state

Parameters:

  • round_state: the round state to update

Errors:

  • returns an error of the existing round state could not be found or updated
Source

fn remove_round_state<'life0, 'life1, 'async_trait>( &'life0 self, round_state: &'life1 StoredRoundState, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a pending round state from the db

Parameters:

  • round_state: the round state to remove

Errors:

  • returns an error of the existing round state could not be found or removed
Source

fn get_round_state_by_id<'life0, 'async_trait>( &'life0 self, id: RoundStateId, ) -> Pin<Box<dyn Future<Output = Result<Option<StoredRoundState<Unlocked>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load a single round state by its id

Returns:

  • Option<StoredRoundState>: the stored round state if found, None otherwise

Errors:

  • returns an error of the states could not be succesfully retrieved
Source

fn get_pending_round_state_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<RoundStateId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load all pending round states from the db

Returns:

  • Vec<RoundStateId>: unordered vector with all stored round state ids

Errors:

  • returns an error of the ids could not be succesfully retrieved
Source

fn store_vtxos<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, vtxos: &'life1 [(&'life2 Vtxo<Full>, &'life3 VtxoState)], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Stores VTXOs with their initial state.

This operation is idempotent: if a VTXO already exists (same id), the implementation should succeed without modifying the existing VTXO or its state. This allows safe retries during crash recovery scenarios.

§Parameters
  • vtxos: Slice of VTXO and state pairs to store.
§Behavior
  • For each VTXO that does not exist: inserts the VTXO and its initial state.
  • For each VTXO that already exists: no-op for that VTXO.
§Errors
  • Returns an error if the storage operation fails.
Source

fn get_wallet_vtxo<'life0, 'async_trait>( &'life0 self, id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<Option<WalletVtxo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a wallet Vtxo with its current state by ID.

Parameters:

Returns:

  • Ok(Some(WalletVtxo)) if found,
  • Ok(None) otherwise.

Errors:

  • Returns an error if the lookup fails.
Source

fn get_all_vtxos<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<WalletVtxo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch all wallet VTXOs in the database.

Returns:

  • Ok(Vec<WalletVtxo>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn get_vtxos_by_state<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 [VtxoStateKind], ) -> Pin<Box<dyn Future<Output = Result<Vec<WalletVtxo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch all wallet VTXOs whose state matches any of the provided kinds.

Parameters:

  • state: Slice of VtxoStateKind filters.

Returns:

  • Ok(Vec<WalletVtxo>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn remove_vtxo<'life0, 'async_trait>( &'life0 self, id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<Option<Vtxo<Full>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a Vtxo by ID.

Parameters:

  • id: VtxoId to remove.

Returns:

  • Ok(Some(Vtxo)) with the removed Vtxo data if it existed,
  • Ok(None) otherwise.

Errors:

  • Returns an error if the delete operation fails.
Source

fn has_spent_vtxo<'life0, 'async_trait>( &'life0 self, id: VtxoId, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check whether a Vtxo is already marked spent.

Parameters:

  • id: VtxoId to check.

Returns:

  • Ok(true) if spent,
  • Ok(false) if not found or not spent.

Errors:

  • Returns an error if the lookup fails.
Source

fn store_vtxo_key<'life0, 'async_trait>( &'life0 self, index: u32, public_key: PublicKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a newly derived/assigned Vtxo public key index mapping.

Parameters:

  • index: Derivation index.
  • public_key: PublicKey at that index.

Errors:

  • Returns an error if the mapping cannot be stored.
Source

fn get_last_vtxo_key_index<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the last revealed/used Vtxo key index.

Returns:

  • Ok(Some(u32)) if a key was stored
  • Ok(None) otherwise.

Errors:

  • Returns an error if the query fails.
Source

fn get_public_key_idx<'life0, 'life1, 'async_trait>( &'life0 self, public_key: &'life1 PublicKey, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves the derivation index of the provided PublicKey from the database

Returns:

  • Ok(Some(u32)) if the key was stored.
  • Ok(None) if the key was not stored.

Errors:

  • Returns an error if the query fails.
Source

fn get_mailbox_checkpoint<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves the mailbox checkpoint from the database

Returns:

  • Ok(u64) the stored checkpoint.

Errors:

  • Returns an error if the query fails.
Source

fn store_mailbox_checkpoint<'life0, 'async_trait>( &'life0 self, checkpoint: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the mailbox checkpoint to the new checkpoint

Returns:

Errors:

  • Returns error when the query fails
  • Returns error when the provided checkpoint is smaller than the existing checkpoint
Source

fn store_new_pending_lightning_send<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, invoice: &'life1 Invoice, amount: Amount, fee: Amount, vtxos: &'life2 [VtxoId], movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<LightningSend>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a new pending lightning send.

Parameters:

  • invoice: The invoice of the pending lightning send.
  • amount: The amount of the pending lightning send.
  • fee: The fee of the pending lightning send.
  • vtxos: The vtxos of the pending lightning send.
  • movement_id: The movement ID associated with this send.

Errors:

  • Returns an error if the pending lightning send cannot be stored.
Source

fn get_all_pending_lightning_send<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<LightningSend>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all pending lightning sends.

Returns:

  • Ok(Vec<LightningSend>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn finish_lightning_send<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, preimage: Option<Preimage>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a lightning send as finished.

Parameters:

  • payment_hash: The PaymentHash of the lightning send to update.
  • preimage: The Preimage of the successful lightning send.

Errors:

  • Returns an error if the lightning send cannot be updated.
Source

fn remove_lightning_send<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a lightning send.

Parameters:

  • payment_hash: The PaymentHash of the lightning send to remove.

Errors:

  • Returns an error if the lightning send cannot be removed.
Source

fn get_lightning_send<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<Option<LightningSend>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a lightning send by payment hash

Parameters:

  • payment_hash: The PaymentHash of the lightning send to get.

Errors:

  • Returns an error if the lookup fails.
Source

fn store_lightning_receive<'life0, 'life1, 'async_trait>( &'life0 self, payment_hash: PaymentHash, preimage: Preimage, invoice: &'life1 Bolt11Invoice, htlc_recv_cltv_delta: BlockDelta, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store an incoming Lightning receive record.

Parameters:

  • payment_hash: Unique payment hash.
  • preimage: Payment preimage (kept until disclosure).
  • invoice: The associated BOLT11 invoice.
  • htlc_recv_cltv_delta: The CLTV delta for the HTLC VTXO.

Errors:

  • Returns an error if the receive cannot be stored.
Source

fn get_all_pending_lightning_receives<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<LightningReceive>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a list of all pending lightning receives

Returns:

  • Ok(Vec<LightningReceive>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn set_preimage_revealed<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a Lightning receive preimage as revealed (e.g., after settlement).

Parameters:

  • payment_hash: The payment hash identifying the receive.

Errors:

  • Returns an error if the update fails or the receive does not exist.
Source

fn update_lightning_receive<'life0, 'life1, 'async_trait>( &'life0 self, payment_hash: PaymentHash, htlc_vtxo_ids: &'life1 [VtxoId], movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set the VTXO IDs and MovementId for a LightningReceive.

Parameters:

  • payment_hash: The payment hash identifying the receive.
  • htlc_vtxo_ids: The VTXO IDs to set.
  • movement_id: The movement ID associated with the invoice.

Errors:

  • Returns an error if the update fails or the receive does not exist.
Source

fn fetch_lightning_receive_by_payment_hash<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<Option<LightningReceive>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a Lightning receive by its payment hash.

Parameters:

  • payment_hash: The payment hash to look up.

Returns:

  • Ok(Some(LightningReceive)) if found,
  • Ok(None) otherwise.

Errors:

  • Returns an error if the lookup fails.
Source

fn finish_pending_lightning_receive<'life0, 'async_trait>( &'life0 self, payment_hash: PaymentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a Lightning receive as finished by its payment hash.

Parameters:

  • payment_hash: The payment hash of the record to mark finished

Errors:

  • Returns an error if the operation fails.
Source

fn store_exit_vtxo_entry<'life0, 'life1, 'async_trait>( &'life0 self, exit: &'life1 StoredExit, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store an entry indicating a Vtxo is being exited.

Parameters:

  • exit: StoredExit describing the exit operation.

Errors:

  • Returns an error if the entry cannot be stored.
Source

fn remove_exit_vtxo_entry<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 VtxoId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove an exit entry for a given Vtxo ID.

Parameters:

  • id: VtxoId to remove from exit tracking.

Errors:

  • Returns an error if the removal fails.
Source

fn get_exit_vtxo_entries<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredExit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all VTXOs currently tracked as being exited.

Returns:

  • Ok(Vec<StoredExit>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn store_exit_child_tx<'life0, 'life1, 'async_trait>( &'life0 self, exit_txid: Txid, child_tx: &'life1 Transaction, origin: ExitTxOrigin, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a child transaction related to an exit transaction.

Parameters:

  • exit_txid: The parent exit transaction ID.
  • child_tx: The child bitcoin Transaction to store.
  • origin: Metadata describing where the child came from (ExitTxOrigin).

Errors:

  • Returns an error if the transaction cannot be stored.
Source

fn get_exit_child_tx<'life0, 'async_trait>( &'life0 self, exit_txid: Txid, ) -> Pin<Box<dyn Future<Output = Result<Option<(Transaction, ExitTxOrigin)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a stored child transaction for a given exit transaction ID.

Parameters:

  • exit_txid: The parent exit transaction ID.

Returns:

  • Ok(Some((Transaction, ExitTxOrigin))) if found,
  • Ok(None) otherwise.

Errors:

  • Returns an error if the lookup fails.
Source

fn update_vtxo_state_checked<'life0, 'life1, 'async_trait>( &'life0 self, vtxo_id: VtxoId, new_state: VtxoState, allowed_old_states: &'life1 [VtxoStateKind], ) -> Pin<Box<dyn Future<Output = Result<WalletVtxo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Updates the state of the VTXO corresponding to the given VtxoId, provided that their current state is one of the given allowed_states.

§Parameters
  • vtxo_id: The ID of the Vtxo to update.
  • state: The new state to be set for the specified Vtxo.
  • allowed_states: An iterable collection of allowed states (VtxoStateKind) that the Vtxo must currently be in for their state to be updated to the new state.
§Returns
  • Ok(WalletVtxo) if the state update is successful.
  • Err(anyhow::Error) if the VTXO fails to meet the required conditions, or if another error occurs during the operation.
§Errors
  • Returns an error if the current state is not within the allowed_states.
  • Returns an error for any other issues encountered during the operation.
Source

fn store_pending_offboard<'life0, 'life1, 'async_trait>( &'life0 self, pending: &'life1 PendingOffboard, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a pending offboard record.

Parameters:

Errors:

  • Returns an error if the record cannot be stored.
Source

fn get_pending_offboards<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<PendingOffboard>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all pending offboard records.

Returns:

  • Ok(Vec<PendingOffboard>) possibly empty.

Errors:

  • Returns an error if the query fails.
Source

fn remove_pending_offboard<'life0, 'async_trait>( &'life0 self, movement_id: MovementId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a pending offboard record by its MovementId.

Parameters:

Errors:

  • Returns an error if the record cannot be removed.

Provided Methods§

Source

fn is_initialized<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the wallet is initialized.

Returns:

  • Ok(true) if the wallet is initialized.
  • Ok(false) if the wallet is not initialized.

Errors:

  • Returns an error if the query fails.

Implementors§

Source§

impl BarkPersister for SqliteClient

Source§

impl<S: StorageAdaptor> BarkPersister for StorageAdaptorWrapper<S>

Blanket implementation of BarkPersister for any type implementing StorageAdaptor.