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>
This commit is contained in:
dni ⚡ 2023-04-03 15:34:55 +02:00 committed by GitHub
parent 689c443d72
commit e59a218912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)