refactor: only use one (direction) flag for identifying payment

This commit is contained in:
Vlad Stan
2022-12-22 12:23:46 +02:00
parent a434731729
commit 98e0ea5ae2
2 changed files with 17 additions and 15 deletions
+1 -7
View File
@@ -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}",