From 9c126696fc63bbafd2c1ebaa0ab3a49b2c4243b3 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 5 Jan 2021 22:28:57 -0300 Subject: [PATCH] delete pending payments after WALLET.pay_invoice fails. fixes https://github.com/lnbits/lnbits/issues/138 --- lnbits/core/services.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 82409b051..266e36a84 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -139,10 +139,12 @@ async def pay_invoice( **payment_kwargs, ) await delete_payment(temp_id) + await db.commit() else: + await delete_payment(temp_id) + await db.commit() raise Exception(payment.error_message or "Failed to pay_invoice on backend.") - await db.commit() return invoice.payment_hash