From 232d50baaa03c29da712c4158f7635853ad3f1bb Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:48:59 +0300 Subject: [PATCH] Fix: tasks.py reuse db connection for invoice deletion (#971) * check if wallet exists * check wallet existence in key check * reuse db connection for payment deletion --- lnbits/core/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lnbits/core/models.py b/lnbits/core/models.py index 219380c8..216acafd 100644 --- a/lnbits/core/models.py +++ b/lnbits/core/models.py @@ -174,7 +174,7 @@ class Payment(BaseModel): logger.warning( f"Deleting outgoing failed payment {self.checking_id}: {status}" ) - await self.delete() + await self.delete(conn) elif not status.pending: logger.info( f"Marking '{'in' if self.is_in else 'out'}' {self.checking_id} as not pending anymore: {status}" @@ -182,10 +182,10 @@ class Payment(BaseModel): await self.update_status(status, conn=conn) return status - async def delete(self) -> None: + async def delete(self, conn: Optional[Connection] = None) -> None: from .crud import delete_payment - await delete_payment(self.checking_id) + await delete_payment(self.checking_id, conn=conn) class BalanceCheck(BaseModel):