pub struct MintQuote {
pub id: QuoteId,
pub amount: Option<Amount<CurrencyUnit>>,
pub unit: CurrencyUnit,
pub request: String,
pub expiry: u64,
pub request_lookup_id: PaymentIdentifier,
pub pubkey: Option<PublicKey>,
pub created_time: u64,
pub payments: Vec<IncomingPayment>,
pub payment_method: PaymentMethod,
pub issuance: Vec<Issuance>,
pub extra_json: Option<Value>,
/* private fields */
}Expand description
Mint Quote Info
Fields§
§id: QuoteIdQuote id
amount: Option<Amount<CurrencyUnit>>Amount of quote
unit: CurrencyUnitUnit of quote
request: StringQuote payment request e.g. bolt11
expiry: u64Expiration time of quote
request_lookup_id: PaymentIdentifierValue used by ln backend to look up state of request
pubkey: Option<PublicKey>Pubkey
created_time: u64Unix time quote was created
payments: Vec<IncomingPayment>Payment of payment(s) that filled quote
payment_method: PaymentMethodPayment Method
issuance: Vec<Issuance>Payment of payment(s) that filled quote
extra_json: Option<Value>Extra payment-method-specific fields
Implementations§
Source§impl MintQuote
impl MintQuote
Sourcepub fn new(
id: Option<QuoteId>,
request: String,
unit: CurrencyUnit,
amount: Option<Amount<CurrencyUnit>>,
expiry: u64,
request_lookup_id: PaymentIdentifier,
pubkey: Option<PublicKey>,
amount_paid: Amount<CurrencyUnit>,
amount_issued: Amount<CurrencyUnit>,
payment_method: PaymentMethod,
created_time: u64,
payments: Vec<IncomingPayment>,
issuance: Vec<Issuance>,
extra_json: Option<Value>,
) -> Self
pub fn new( id: Option<QuoteId>, request: String, unit: CurrencyUnit, amount: Option<Amount<CurrencyUnit>>, expiry: u64, request_lookup_id: PaymentIdentifier, pubkey: Option<PublicKey>, amount_paid: Amount<CurrencyUnit>, amount_issued: Amount<CurrencyUnit>, payment_method: PaymentMethod, created_time: u64, payments: Vec<IncomingPayment>, issuance: Vec<Issuance>, extra_json: Option<Value>, ) -> Self
Create new MintQuote
Sourcepub fn increment_amount_paid(
&mut self,
additional_amount: Amount<CurrencyUnit>,
) -> Result<Amount, Error>
pub fn increment_amount_paid( &mut self, additional_amount: Amount<CurrencyUnit>, ) -> Result<Amount, Error>
Increment the amount paid on the mint quote by a given amount
Sourcepub fn amount_paid(&self) -> Amount<CurrencyUnit>
pub fn amount_paid(&self) -> Amount<CurrencyUnit>
Amount paid
Sourcepub fn add_issuance(
&mut self,
additional_amount: Amount<CurrencyUnit>,
) -> Result<Amount<CurrencyUnit>, Error>
pub fn add_issuance( &mut self, additional_amount: Amount<CurrencyUnit>, ) -> Result<Amount<CurrencyUnit>, Error>
Records tokens being issued against this mint quote.
This method validates that the issuance doesn’t exceed the amount paid, updates
the quote’s internal state, and records the change for later persistence. The
amount_issued counter is incremented and the issuance is added to the change
tracker for the database layer to persist.
§Arguments
additional_amount- The amount of tokens being issued.
§Returns
Returns the new total amount_issued after this issuance is recorded.
§Errors
Returns crate::Error::OverIssue if the new issued amount would exceed the
amount paid (cannot issue more tokens than have been paid for).
Returns crate::Error::AmountOverflow if adding the issuance amount would
cause an arithmetic overflow.
Sourcepub fn amount_issued(&self) -> Amount<CurrencyUnit>
pub fn amount_issued(&self) -> Amount<CurrencyUnit>
Amount issued
Sourcepub fn state(&self) -> MintQuoteState
pub fn state(&self) -> MintQuoteState
Get state of mint quote
Sourcepub fn payment_ids(&self) -> Vec<&String>
pub fn payment_ids(&self) -> Vec<&String>
Existing payment ids of a mint quote
Sourcepub fn amount_mintable(&self) -> Amount<CurrencyUnit>
pub fn amount_mintable(&self) -> Amount<CurrencyUnit>
Amount mintable Returns the amount that is still available for minting.
The value is computed as the difference between the total amount that
has been paid for this issuance (self.amount_paid) and the amount
that has already been issued (self.amount_issued). In other words,
Sourcepub fn take_changes(&mut self) -> Option<MintQuoteChange>
pub fn take_changes(&mut self) -> Option<MintQuoteChange>
Extracts and returns all pending changes, leaving the internal change tracker empty.
This method is typically called by the database layer after loading or modifying a quote. It
returns any accumulated changes (new payments, issuances) that need to be persisted, and
clears the internal change buffer so that subsequent calls return None until new
modifications are made.
Returns None if no changes have been made since the last call to this method or since the
quote was created/loaded.
Sourcepub fn add_payment(
&mut self,
amount: Amount<CurrencyUnit>,
payment_id: String,
time: Option<u64>,
) -> Result<(), Error>
pub fn add_payment( &mut self, amount: Amount<CurrencyUnit>, payment_id: String, time: Option<u64>, ) -> Result<(), Error>
Records a new payment received for this mint quote.
This method validates the payment, updates the quote’s internal state, and records the
change for later persistence. The amount_paid counter is incremented and the payment is
added to the change tracker for the database layer to persist.
§Arguments
amount- The amount of the payment in the quote’s currency unit. *payment_id- A unique identifier for this payment (e.g., lightning payment hash). *time- Optional Unix timestamp of when the payment was received. IfNone, the current time is used.
§Errors
Returns crate::Error::DuplicatePaymentId if a payment with the same ID has already been
recorded for this quote.
Returns crate::Error::AmountOverflow if adding the payment amount would cause an
arithmetic overflow.