diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index 4122f9026..ecc27a9cf 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -452,6 +452,15 @@ async def delete_payment(checking_id: str, conn: Optional[Connection] = None) -> ) +async def delete_wallet_payment( + checking_id: str, wallet_id: str, conn: Optional[Connection] = None +) -> None: + await (conn or db).execute( + "DELETE FROM apipayments WHERE checking_id = ? AND wallet = ?", + (checking_id, wallet_id), + ) + + async def check_internal( payment_hash: str, conn: Optional[Connection] = None ) -> Optional[str]: diff --git a/lnbits/core/services.py b/lnbits/core/services.py index a6e0b43a3..10693f4b9 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -28,7 +28,7 @@ from . import db from .crud import ( check_internal, create_payment, - delete_payment, + delete_wallet_payment, get_wallet, get_wallet_payment, update_payment_details, @@ -221,7 +221,7 @@ async def pay_invoice( logger.warning(f"backend sent payment failure") async with db.connect() as conn: logger.debug(f"deleting temporary payment {temp_id}") - await delete_payment(temp_id, conn=conn) + await delete_wallet_payment(temp_id, wallet_id, conn=conn) raise PaymentFailure( f"payment failed: {payment.error_message}" or "payment failed, but backend didn't give us an error message"