Skip to main content

QuotesTransaction

Trait QuotesTransaction 

Source
pub trait QuotesTransaction {
    type Err: Into<Error> + From<Error>;

Show 16 methods // Required methods fn add_melt_request<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, inputs_amount: Amount<CurrencyUnit>, inputs_fee: Amount<CurrencyUnit>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_blinded_messages<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, quote_id: Option<&'life1 QuoteId>, blinded_messages: &'life2 [BlindedMessage], operation: &'life3 Operation, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn delete_blinded_messages<'life0, 'life1, 'async_trait>( &'life0 mut self, blinded_secrets: &'life1 [PublicKey], ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_melt_request_and_blinded_messages<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<MeltRequestInfo>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_melt_request<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_mint_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintMintQuote>>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_mint_quote<'life0, 'async_trait>( &'life0 mut self, quote: MintMintQuote, ) -> Pin<Box<dyn Future<Output = Result<Acquired<MintMintQuote>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_mint_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MintQuote>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_melt_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MeltQuote>>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_melt_quote<'life0, 'async_trait>( &'life0 mut self, quote: MeltQuote, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_melt_quotes_by_request_lookup_id<'life0, 'life1, 'async_trait>( &'life0 mut self, request_lookup_id: &'life1 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Vec<Acquired<MeltQuote>>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn lock_melt_quote_and_related<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<LockedMeltQuotes, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update_melt_quote_request_lookup_id<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MeltQuote>, new_request_lookup_id: &'life2 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn update_melt_quote_state<'life0, 'life1, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MeltQuote>, new_state: MeltQuoteState, payment_proof: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<MeltQuoteState, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_mint_quote_by_request<'life0, 'life1, 'async_trait>( &'life0 mut self, request: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintMintQuote>>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_mint_quote_by_request_lookup_id<'life0, 'life1, 'async_trait>( &'life0 mut self, request_lookup_id: &'life1 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintMintQuote>>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait;
}
Expand description

Mint Quote Database writer trait

Required Associated Types§

Source

type Err: Into<Error> + From<Error>

Mint Quotes Database Error

Required Methods§

Source

fn add_melt_request<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, inputs_amount: Amount<CurrencyUnit>, inputs_fee: Amount<CurrencyUnit>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add melt_request with quote_id, inputs_amount, and inputs_fee

Source

fn add_blinded_messages<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, quote_id: Option<&'life1 QuoteId>, blinded_messages: &'life2 [BlindedMessage], operation: &'life3 Operation, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add blinded_messages for a quote_id

Source

fn delete_blinded_messages<'life0, 'life1, 'async_trait>( &'life0 mut self, blinded_secrets: &'life1 [PublicKey], ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete blinded_messages by their blinded secrets

Source

fn get_melt_request_and_blinded_messages<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<MeltRequestInfo>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get melt_request and associated blinded_messages by quote_id

Source

fn delete_melt_request<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete melt_request and associated blinded_messages by quote_id

Source

fn get_mint_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintMintQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get MintMintQuote and lock it for update in this transaction

Source

fn add_mint_quote<'life0, 'async_trait>( &'life0 mut self, quote: MintMintQuote, ) -> Pin<Box<dyn Future<Output = Result<Acquired<MintMintQuote>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn update_mint_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MintQuote>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persists any pending changes made to the mint quote.

This method extracts changes accumulated in the quote (via mint::MintQuote::take_changes) and persists them to the database. Changes may include new payments received or new issuances recorded against the quote.

If no changes are pending, this method returns successfully without performing any database operations.

§Arguments
  • quote - A mutable reference to an acquired (row-locked) mint quote. The quote must be locked to ensure transactional consistency when persisting changes.
§Implementation Notes

Implementations should call mint::MintQuote::take_changes to retrieve pending changes, then persist each payment and issuance record, and finally update the quote’s aggregate counters (amount_paid, amount_issued) in the database.

Source

fn get_melt_quote<'life0, 'life1, 'async_trait>( &'life0 mut self, quote_id: &'life1 QuoteId, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MeltQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get mint::MeltQuote and lock it for update in this transaction

Source

fn add_melt_quote<'life0, 'async_trait>( &'life0 mut self, quote: MeltQuote, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_melt_quotes_by_request_lookup_id<'life0, 'life1, 'async_trait>( &'life0 mut self, request_lookup_id: &'life1 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Vec<Acquired<MeltQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves all melt quotes matching a payment lookup identifier and locks them for update.

This method returns multiple quotes because certain payment methods (notably BOLT12 offers) can generate multiple payment attempts that share the same lookup identifier. Locking all related quotes prevents race conditions where concurrent melt operations could interfere with each other, potentially leading to double-spending or state inconsistencies.

The returned quotes are locked within the current transaction to ensure safe concurrent modification. This is essential during melt saga initiation and finalization to guarantee atomic state transitions across all related quotes.

§Arguments
  • request_lookup_id - The payment identifier used by the Lightning backend to track payment state (e.g., payment hash, offer ID, or label).

Locks a melt quote and all related quotes sharing the same request_lookup_id atomically.

This method prevents deadlocks by acquiring all locks in a single query with consistent ordering, rather than locking the target quote first and then related quotes separately.

§Deadlock Prevention

When multiple transactions try to melt quotes sharing the same request_lookup_id, acquiring locks in two steps (first the target quote, then all related quotes) can cause circular wait deadlocks. This method avoids that by:

  1. Using a subquery to find the request_lookup_id for the target quote
  2. Locking ALL quotes with that request_lookup_id in one atomic operation
  3. Ordering locks consistently by quote ID
§Arguments
  • quote_id - The ID of the target melt quote
§Returns

A LockedMeltQuotes containing:

  • target: The target quote (if found)
  • all_related: All quotes sharing the same request_lookup_id (including the target)

If the quote has no request_lookup_id, only the target quote is returned and locked.

Source

fn update_melt_quote_request_lookup_id<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MeltQuote>, new_request_lookup_id: &'life2 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Updates the request lookup id for a melt quote.

Requires an Acquired melt quote to ensure the row is locked before modification.

Source

fn update_melt_quote_state<'life0, 'life1, 'async_trait>( &'life0 mut self, quote: &'life1 mut Acquired<MeltQuote>, new_state: MeltQuoteState, payment_proof: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<MeltQuoteState, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update mint::MeltQuote state.

Requires an Acquired melt quote to ensure the row is locked before modification. Returns the previous state.

Source

fn get_mint_quote_by_request<'life0, 'life1, 'async_trait>( &'life0 mut self, request: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintMintQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all MintMintQuotes and lock it for update in this transaction

Source

fn get_mint_quote_by_request_lookup_id<'life0, 'life1, 'async_trait>( &'life0 mut self, request_lookup_id: &'life1 PaymentIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Option<Acquired<MintMintQuote>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all MintMintQuotes

Implementors§