diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index b38a3d144..a80fadf29 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -455,20 +455,14 @@ async def update_payment_extra( payment_hash: str, extra: dict, outgoing: bool = False, - incoming: bool = False, conn: Optional[Connection] = None, ) -> None: """ Only update the `extra` field for the payment. Old values in the `extra` JSON object will be kept unless the new `extra` overwrites them. """ - amount_clause = "" - if outgoing != incoming: - if outgoing: - amount_clause = "AND amount < 0" - else: - amount_clause = "AND amount > 0" + amount_clause = "AND amount < 0" if outgoing else "AND amount > 0" row = await (conn or db).fetchone( f"SELECT hash, extra from apipayments WHERE hash = ? {amount_clause}", diff --git a/lnbits/extensions/lnurlp/tasks.py b/lnbits/extensions/lnurlp/tasks.py index e243e1a4e..b8da5e436 100644 --- a/lnbits/extensions/lnurlp/tasks.py +++ b/lnbits/extensions/lnurlp/tasks.py @@ -52,21 +52,29 @@ async def on_invoice_paid(payment: Payment) -> None: r: httpx.Response = await client.post(pay_link.webhook_url, **kwargs) await mark_webhook_sent( - payment, r.status_code, r.is_success, r.reason_phrase, r.text + payment.payment_hash, + r.status_code, + r.is_success, + r.reason_phrase, + r.text, ) except Exception as ex: logger.error(ex) - await mark_webhook_sent(payment, -1, False, "Unexpected Error", str(ex)) + await mark_webhook_sent( + payment.payment_hash, -1, False, "Unexpected Error", str(ex) + ) async def mark_webhook_sent( - payment: Payment, status: int, is_success: bool, reason_phrase="", text="" + payment_hash: str, status: int, is_success: bool, reason_phrase="", text="" ) -> None: - payment.extra["wh_status"] = status # keep for backwards compability - payment.extra["wh_success"] = is_success - payment.extra["wh_message"] = reason_phrase - payment.extra["wh_response"] = text await update_payment_extra( - payment_hash=payment.payment_hash, extra=payment.extra, incoming=True + payment_hash, + { + "wh_status": status, # keep for backwards compability + "wh_success": is_success, + "wh_message": reason_phrase, + "wh_response": text, + }, )