diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 8c782b86..5322de77 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)