From e59a21891247d5950d0e238feddb50047a174d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 3 Apr 2023 15:34:55 +0200 Subject: [PATCH] bugfix: 500 error if same wallet tries to pay an external invoice twice (#1594) * bugfix: 500 error if same wallet tries to pay an external invoice twice * fstring * log the error --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com> --- lnbits/core/services.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 8c782b860..5322de778 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -174,12 +174,17 @@ async def pay_invoice( logger.debug(f"creating temporary payment with id {temp_id}") # create a temporary payment here so we can check if # the balance is enough in the next step - await create_payment( - checking_id=temp_id, - fee=-fee_reserve_msat, - conn=conn, - **payment_kwargs, - ) + try: + await create_payment( + checking_id=temp_id, + fee=-fee_reserve_msat, + conn=conn, + **payment_kwargs, + ) + except Exception as e: + logger.error(f"could not create temporary payment: {e}") + # happens if the same wallet tries to pay an invoice twice + raise PaymentFailure("Could not make payment.") # do the balance check wallet = await get_wallet(wallet_id, conn=conn)