mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-29 05:12:39 +02:00
fix internal payment check (#1604)
This commit is contained in:
@@ -597,6 +597,7 @@ async def check_internal(
|
||||
async def check_internal_pending(
|
||||
payment_hash: str, conn: Optional[Connection] = None
|
||||
) -> bool:
|
||||
"""Returns False if the internal payment is not pending anymore (and thus paid), otherwise True"""
|
||||
row = await (conn or db).fetchone(
|
||||
"""
|
||||
SELECT pending FROM apipayments
|
||||
@@ -605,7 +606,7 @@ async def check_internal_pending(
|
||||
(payment_hash,),
|
||||
)
|
||||
if not row:
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return row["pending"]
|
||||
|
||||
|
@@ -154,10 +154,11 @@ async def pay_invoice(
|
||||
extra=extra,
|
||||
)
|
||||
|
||||
# we check if an internal invoice exists that has already been paid (not pending anymore)
|
||||
if not await check_internal_pending(invoice.payment_hash, conn=conn):
|
||||
raise PaymentFailure("Internal invoice already paid.")
|
||||
|
||||
# check_internal() returns the checking_id of the invoice we're waiting for
|
||||
# check_internal() returns the checking_id of the invoice we're waiting for (pending only)
|
||||
internal_checking_id = await check_internal(invoice.payment_hash, conn=conn)
|
||||
if internal_checking_id:
|
||||
logger.debug(f"creating temporary internal payment with id {internal_id}")
|
||||
|
Reference in New Issue
Block a user