From a434731729db18632e134fa9ccceb709f3aed3fd Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 22 Dec 2022 11:28:12 +0200 Subject: [PATCH] fix: update the rest of `update_payment_extra` calls --- lnbits/core/crud.py | 6 +++--- lnbits/extensions/lnurlp/tasks.py | 4 +++- lnbits/extensions/withdraw/lnurl.py | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index bed28111..b38a3d14 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -452,7 +452,7 @@ async def update_payment_details( async def update_payment_extra( - hash: str, + payment_hash: str, extra: dict, outgoing: bool = False, incoming: bool = False, @@ -472,7 +472,7 @@ async def update_payment_extra( row = await (conn or db).fetchone( f"SELECT hash, extra from apipayments WHERE hash = ? {amount_clause}", - (hash,), + (payment_hash,), ) if not row: return @@ -481,7 +481,7 @@ async def update_payment_extra( await (conn or db).execute( f"UPDATE apipayments SET extra = ? WHERE hash = ? {amount_clause} ", - (json.dumps(db_extra), hash), + (json.dumps(db_extra), payment_hash), ) diff --git a/lnbits/extensions/lnurlp/tasks.py b/lnbits/extensions/lnurlp/tasks.py index 72805603..e243e1a4 100644 --- a/lnbits/extensions/lnurlp/tasks.py +++ b/lnbits/extensions/lnurlp/tasks.py @@ -67,4 +67,6 @@ async def mark_webhook_sent( payment.extra["wh_message"] = reason_phrase payment.extra["wh_response"] = text - await update_payment_extra(payment.payment_hash, payment.extra) + await update_payment_extra( + payment_hash=payment.payment_hash, extra=payment.extra, incoming=True + ) diff --git a/lnbits/extensions/withdraw/lnurl.py b/lnbits/extensions/withdraw/lnurl.py index 48ccaf4a..86640443 100644 --- a/lnbits/extensions/withdraw/lnurl.py +++ b/lnbits/extensions/withdraw/lnurl.py @@ -163,7 +163,7 @@ async def api_lnurl_callback( r: httpx.Response = await client.post(link.webhook_url, **kwargs) await update_payment_extra( - hash=payment_hash, + payment_hash=payment_hash, extra={ "wh_success": r.is_success, "wh_message": r.reason_phrase, @@ -177,8 +177,9 @@ async def api_lnurl_callback( "Caught exception when dispatching webhook url: " + str(exc) ) await update_payment_extra( - payment_hash, - {"wh_success": False, "wh_message": str(exc)}, + payment_hash=payment_hash, + extra={"wh_success": False, "wh_message": str(exc)}, + outgoing=True, ) return {"status": "OK"}