Core: fix internal webhooks (#649)

* fix internal webhooks

* argument annotation
This commit is contained in:
calle 2022-06-03 14:33:31 +02:00 committed by GitHub
parent b03da7b9c2
commit 906f0166bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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),

View File

@ -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: