mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 03:24:18 +01:00
refactor melt quote (#530)
This commit is contained in:
@@ -616,18 +616,15 @@ class Ledger(LedgerVerification, LedgerSpendingConditions):
|
|||||||
expiry=quote.expiry,
|
expiry=quote.expiry,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_melt_quote(
|
async def get_melt_quote(self, quote_id: str) -> MeltQuote:
|
||||||
self, quote_id: str, check_quote_with_backend: bool = False
|
|
||||||
) -> MeltQuote:
|
|
||||||
"""Returns a melt quote.
|
"""Returns a melt quote.
|
||||||
|
|
||||||
If melt quote is not paid yet and `check_quote_with_backend` is set to `True`,
|
If melt quote is not paid yet and no internal mint quote is associated with it,
|
||||||
checks with the backend for the state of the payment request. If the backend
|
checks with the backend for the state of the payment request. If the backend
|
||||||
says that the quote has been paid, updates the melt quote in the database.
|
says that the quote has been paid, updates the melt quote in the database.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
quote_id (str): ID of the melt quote.
|
quote_id (str): ID of the melt quote.
|
||||||
check_quote_with_backend (bool, optional): Whether to check the state of the payment request with the backend. Defaults to False.
|
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
Exception: Quote not found.
|
Exception: Quote not found.
|
||||||
@@ -649,7 +646,7 @@ class Ledger(LedgerVerification, LedgerSpendingConditions):
|
|||||||
request=melt_quote.request, db=self.db
|
request=melt_quote.request, db=self.db
|
||||||
)
|
)
|
||||||
|
|
||||||
if not melt_quote.paid and not mint_quote and check_quote_with_backend:
|
if not melt_quote.paid and not mint_quote:
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"Lightning: checking outgoing Lightning payment"
|
"Lightning: checking outgoing Lightning payment"
|
||||||
f" {melt_quote.checking_id}"
|
f" {melt_quote.checking_id}"
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ async def mint(
|
|||||||
response_description="Melt tokens for a payment on a supported payment method.",
|
response_description="Melt tokens for a payment on a supported payment method.",
|
||||||
)
|
)
|
||||||
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
|
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
|
||||||
async def get_melt_quote(
|
async def melt_quote(
|
||||||
request: Request, payload: PostMeltQuoteRequest
|
request: Request, payload: PostMeltQuoteRequest
|
||||||
) -> PostMeltQuoteResponse:
|
) -> PostMeltQuoteResponse:
|
||||||
"""
|
"""
|
||||||
@@ -277,7 +277,7 @@ async def get_melt_quote(
|
|||||||
response_description="Get an existing melt quote to check its status.",
|
response_description="Get an existing melt quote to check its status.",
|
||||||
)
|
)
|
||||||
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
|
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
|
||||||
async def melt_quote(request: Request, quote: str) -> PostMeltQuoteResponse:
|
async def get_melt_quote(request: Request, quote: str) -> PostMeltQuoteResponse:
|
||||||
"""
|
"""
|
||||||
Get melt quote state.
|
Get melt quote state.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user