Skip to main content

SqliteClient

Struct SqliteClient 

Source
pub struct SqliteClient { /* private fields */ }
Expand description

An implementation of the BarkPersister using rusqlite. Changes are persisted using the given PathBuf.

Implementations§

Source§

impl SqliteClient

Source

pub fn open(db_file: impl AsRef<Path>) -> Result<SqliteClient>

Open a new SqliteClient with the given file path

Trait Implementations§

Source§

impl BarkPersister for SqliteClient

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,

Get all VTXOs that are in one of the provided states

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. Read more
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. Read more
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. Read more
Source§

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

Set the server’s mailbox public key in wallet properties. Read more
Source§

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

Creates a new movement in the given state, ready to be updated. Read more
Source§

fn get_or_create_movement_for_action<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, subsystem: &'life1 MovementSubsystem, time: DateTime<Local>, action_id: &'life2 str, update: MovementUpdate, ) -> Pin<Box<dyn Future<Output = Result<(MovementId, bool)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Atomically look up the movement owned by action_id, or create it and apply update as its initial state, in a single transaction. Read more
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. Read more
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. Read more
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. Read more
Source§

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

Get all movements for a given payment method Read more
Source§

fn store_round_state<'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 Read more
Source§

fn update_round_state<'life0, 'life1, 'async_trait>( &'life0 self, 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 Read more
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 Read more
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 Read more
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 Read more
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. Read more
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. Read more
Source§

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

Fetch multiple wallet VTXOs by id, preserving the order of the input slice. Read more
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. Read more
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. Read more
Source§

fn get_full_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,

Fetch a single VTXO in full form (including the unilateral exit chain). Read more
Source§

fn get_full_vtxos<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [VtxoId], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vtxo<Full>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Hydrate a batch of VTXOs into their full form, preserving the order of the input slice. Returns an error if any id is missing — callers reach this from a selection step against the wallet’s listings, so a missing row indicates the wallet’s state is inconsistent with the caller’s view.
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. Read more
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. Read more
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. Read more
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 Read more
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 Read more
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 Read more
Source§

fn upsert_wallet_action_checkpoint<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 WalletActionId, checkpoint: &'life2 WalletActionCheckpoint, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Persist or overwrite a wallet action checkpoint. Read more
Source§

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

Fetch a wallet action checkpoint by id. Read more
Source§

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

Fetch every persisted wallet action checkpoint, oldest first. Read more
Source§

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

Remove a wallet action checkpoint by id. No-op if absent.
Source§

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

Record a settled outgoing lightning send. Read more
Source§

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

Look up an existing paid-invoice record by payment hash.
Source§

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

Record a settled incoming lightning receive, ignore if already exists.
Source§

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

Look up a settled lightning receive record by payment hash.
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. Read more
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. Read more
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. Read more
Source§

fn get_exit_vtxo_entries_with_states<'life0, 'life1, 'async_trait>( &'life0 self, states: &'life1 [ExitStateKind], ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredExit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List exit entries whose current state matches one of the given ExitStateKinds. Read more
Source§

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

Fetch the exit entry for a single Vtxo ID, if any. Read more
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. Read more
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. Read more
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. Read more
Source§

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

Transition multiple VTXOs to new_state atomically: either every vtxo’s state changes or none does. A failure must not affect any vtxo.
Source§

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

Set WalletVtxo::registered on the given VTXOs, recording that their recovery state (mailbox ID post + signed transaction chain) has been asserted with the server so the sync-time catch-up can skip them.
Source§

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

Fetch the IDs of all VTXOs whose recovery state still needs to be asserted with the server: not yet marked WalletVtxo::registered and in any state except VtxoStateKind::Spent, in unspecified order. Read more
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. Read more
Source§

impl Clone for SqliteClient

Source§

fn clone(&self) -> SqliteClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqliteClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more