From a301b97766dc70f126cc7cd851998ec80c802bc1 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 24 Nov 2022 16:55:35 +0200 Subject: [PATCH] refactor: remove duplicate code --- lnbits/extensions/satspay/crud.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/satspay/crud.py b/lnbits/extensions/satspay/crud.py index 23d391b7..512bcaa3 100644 --- a/lnbits/extensions/satspay/crud.py +++ b/lnbits/extensions/satspay/crud.py @@ -98,7 +98,7 @@ async def delete_charge(charge_id: str) -> None: await db.execute("DELETE FROM satspay.charges WHERE id = ?", (charge_id,)) -async def check_address_balance(charge_id: str) -> List[Charges]: +async def check_address_balance(charge_id: str) -> Optional[Charges]: charge = await get_charge(charge_id) if not charge.paid: if charge.onchainaddress: @@ -120,8 +120,7 @@ async def check_address_balance(charge_id: str) -> List[Charges]: if invoice_status["paid"]: return await update_charge(charge_id=charge_id, balance=charge.amount) - row = await db.fetchone("SELECT * FROM satspay.charges WHERE id = ?", (charge_id,)) - return Charges.from_row(row) if row else None + return await get_charge(charge_id) async def get_charge_config(charge_id: str):