Skip to main content

MintQuote

Struct MintQuote 

Source
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: QuoteId

Quote id

§amount: Option<Amount<CurrencyUnit>>

Amount of quote

§unit: CurrencyUnit

Unit of quote

§request: String

Quote payment request e.g. bolt11

§expiry: u64

Expiration time of quote

§request_lookup_id: PaymentIdentifier

Value used by ln backend to look up state of request

§pubkey: Option<PublicKey>

Pubkey

§created_time: u64

Unix time quote was created

§payments: Vec<IncomingPayment>

Payment of payment(s) that filled quote

§payment_method: PaymentMethod

Payment Method

§issuance: Vec<Issuance>

Payment of payment(s) that filled quote

§extra_json: Option<Value>

Extra payment-method-specific fields

Implementations§

Source§

impl MintQuote

Source

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

Source

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

Source

pub fn amount_paid(&self) -> Amount<CurrencyUnit>

Amount paid

Source

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.

Source

pub fn amount_issued(&self) -> Amount<CurrencyUnit>

Amount issued

Source

pub fn state(&self) -> MintQuoteState

Get state of mint quote

Source

pub fn payment_ids(&self) -> Vec<&String>

Existing payment ids of a mint quote

Source

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,

Source

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.

Source

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. If None, 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.

Trait Implementations§

Source§

impl Clone for MintQuote

Source§

fn clone(&self) -> MintQuote

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MintQuote

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<MintQuote> for MintQuoteBolt11Response<QuoteId>

Source§

fn from(mint_quote: MintQuote) -> MintQuoteBolt11Response<QuoteId>

Converts to this type from the input type.
Source§

impl From<MintQuote> for MintQuoteBolt11Response<String>

Source§

fn from(quote: MintQuote) -> Self

Converts to this type from the input type.
Source§

impl Hash for MintQuote

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MintQuote

Source§

fn eq(&self, other: &MintQuote) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<MintQuote> for MintQuoteBolt12Response<QuoteId>

Source§

type Error = Error

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

fn try_from(mint_quote: MintQuote) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<MintQuote> for MintQuoteBolt12Response<String>

Source§

type Error = Error

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

fn try_from(quote: MintQuote) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<MintQuote> for MintQuoteCustomResponse<QuoteId>

Source§

type Error = Error

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

fn try_from(mint_quote: MintQuote) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<MintQuote> for MintQuoteCustomResponse<String>

Source§

type Error = Error

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

fn try_from(quote: MintQuote) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for MintQuote

Source§

impl StructuralPartialEq for MintQuote

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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