mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-02 14:09:26 +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(
|
async def check_internal_pending(
|
||||||
payment_hash: str, conn: Optional[Connection] = None
|
payment_hash: str, conn: Optional[Connection] = None
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
"""Returns False if the internal payment is not pending anymore (and thus paid), otherwise True"""
|
||||||
row = await (conn or db).fetchone(
|
row = await (conn or db).fetchone(
|
||||||
"""
|
"""
|
||||||
SELECT pending FROM apipayments
|
SELECT pending FROM apipayments
|
||||||
@@ -605,7 +606,7 @@ async def check_internal_pending(
|
|||||||
(payment_hash,),
|
(payment_hash,),
|
||||||
)
|
)
|
||||||
if not row:
|
if not row:
|
||||||
return False
|
return True
|
||||||
else:
|
else:
|
||||||
return row["pending"]
|
return row["pending"]
|
||||||
|
|
||||||
|
@@ -154,10 +154,11 @@ async def pay_invoice(
|
|||||||
extra=extra,
|
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):
|
if not await check_internal_pending(invoice.payment_hash, conn=conn):
|
||||||
raise PaymentFailure("Internal invoice already paid.")
|
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)
|
internal_checking_id = await check_internal(invoice.payment_hash, conn=conn)
|
||||||
if internal_checking_id:
|
if internal_checking_id:
|
||||||
logger.debug(f"creating temporary internal payment with id {internal_id}")
|
logger.debug(f"creating temporary internal payment with id {internal_id}")
|
||||||
|
Reference in New Issue
Block a user