Skip to content

Commit

Permalink
Fix: Unset pending melt quote by quote id (#629)
Browse files Browse the repository at this point in the history
* unser melt quote based on quote id

* fixes for lnbits
  • Loading branch information
callebtc authored Oct 2, 2024
1 parent d8d3037 commit f8f061f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions cashu/lightning/lnbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ async def pay_invoice(
)
r.raise_for_status()
except Exception:
error_message = r.json().get("detail") or r.reason_phrase
return PaymentResponse(
result=PaymentResult.FAILED, error_message=r.json()["detail"]
result=PaymentResult.FAILED, error_message=error_message
)
if r.status_code > 299:
return PaymentResponse(
result=PaymentResult.FAILED,
error_message=(f"HTTP status: {r.reason_phrase}",),
)
if "detail" in r.json():
if r.json().get("detail"):
return PaymentResponse(
result=PaymentResult.FAILED, error_message=(r.json()["detail"],)
)

data: dict = r.json()
checking_id = data["payment_hash"]
checking_id = data.get("payment_hash")
if not checking_id:
return PaymentResponse(
result=PaymentResult.UNKNOWN, error_message="No payment_hash received"
)

# we do this to get the fee and preimage
payment: PaymentStatus = await self.get_payment_status(checking_id)
Expand Down
2 changes: 1 addition & 1 deletion cashu/mint/db/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async def _unset_melt_quote_pending(
async with self.db.get_connection(lock_table="melt_quotes") as conn:
# get melt quote from db and check if it is pending
quote_db = await self.crud.get_melt_quote(
checking_id=quote.checking_id, db=self.db, conn=conn
quote_id=quote.quote, db=self.db, conn=conn
)
if not quote_db:
raise TransactionError("Melt quote not found.")
Expand Down

0 comments on commit f8f061f

Please sign in to comment.