Skip to content

Commit

Permalink
refactor melt quote (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored May 22, 2024
1 parent 52fbfc4 commit 71b4051
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,18 +616,15 @@ async def melt_quote(
expiry=quote.expiry,
)

async def get_melt_quote(
self, quote_id: str, check_quote_with_backend: bool = False
) -> MeltQuote:
async def get_melt_quote(self, quote_id: str) -> MeltQuote:
"""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
says that the quote has been paid, updates the melt quote in the database.
Args:
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:
Exception: Quote not found.
Expand All @@ -649,7 +646,7 @@ async def get_melt_quote(
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(
"Lightning: checking outgoing Lightning payment"
f" {melt_quote.checking_id}"
Expand Down
4 changes: 2 additions & 2 deletions cashu/mint/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async def mint(
response_description="Melt tokens for a payment on a supported payment method.",
)
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
async def get_melt_quote(
async def melt_quote(
request: Request, payload: PostMeltQuoteRequest
) -> PostMeltQuoteResponse:
"""
Expand All @@ -277,7 +277,7 @@ async def get_melt_quote(
response_description="Get an existing melt quote to check its status.",
)
@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.
"""
Expand Down
2 changes: 1 addition & 1 deletion cashu/wallet/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ async def invoices(ctx, paid: bool, unpaid: bool, pending: bool, mint: bool):
return

if mint:
await wallet.load_mint()
await wallet.load_mint()

paid_arg = None
if unpaid:
Expand Down

0 comments on commit 71b4051

Please sign in to comment.