From 906f0166bd2ba7083032a4556f61e65d25ade340 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Fri, 3 Jun 2022 14:33:31 +0200 Subject: [PATCH] Core: fix internal webhooks (#649) * fix internal webhooks * argument annotation --- lnbits/core/crud.py | 11 ++++++++--- lnbits/tasks.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index a63f52c4d..e9b28a558 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -180,13 +180,18 @@ async def get_wallet_for_key( async def get_standalone_payment( - checking_id_or_hash: str, conn: Optional[Connection] = None + checking_id_or_hash: str, + conn: Optional[Connection] = None, + incoming: Optional[bool] = False, ) -> Optional[Payment]: + clause: str = "checking_id = ? OR hash = ?" + if incoming: + clause = f"({clause}) AND amount > 0" row = await (conn or db).fetchone( - """ + f""" SELECT * FROM apipayments - WHERE checking_id = ? OR hash = ? + WHERE {clause} LIMIT 1 """, (checking_id_or_hash, checking_id_or_hash), diff --git a/lnbits/tasks.py b/lnbits/tasks.py index 4e73a0af6..34f37a394 100644 --- a/lnbits/tasks.py +++ b/lnbits/tasks.py @@ -114,7 +114,7 @@ async def perform_balance_checks(): async def invoice_callback_dispatcher(checking_id: str): - payment = await get_standalone_payment(checking_id) + payment = await get_standalone_payment(checking_id, incoming=True) if payment and payment.is_in: await payment.set_pending(False) for send_chan in invoice_listeners: