fixup!
This commit is contained in:
+5
-6
@@ -976,23 +976,22 @@ async def check_internal(
|
|||||||
return row["checking_id"]
|
return row["checking_id"]
|
||||||
|
|
||||||
|
|
||||||
async def check_internal_pending(
|
async def check_internal_status(
|
||||||
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
|
Returns True if the internal payment was successful
|
||||||
(and thus paid), otherwise True
|
|
||||||
"""
|
"""
|
||||||
row: dict = await (conn or db).fetchone(
|
row: dict = await (conn or db).fetchone(
|
||||||
"""
|
"""
|
||||||
SELECT status FROM apipayments
|
SELECT status FROM apipayments
|
||||||
WHERE payment_hash = :hash AND amount > 0
|
WHERE payment_hash = :payment_hash AND amount > 0
|
||||||
""",
|
""",
|
||||||
{"hash": payment_hash},
|
{"payment_hash": payment_hash},
|
||||||
)
|
)
|
||||||
if not row:
|
if not row:
|
||||||
return True
|
return True
|
||||||
return row["status"] == PaymentState.PENDING.value
|
return row["status"] == PaymentState.SUCCESS.value
|
||||||
|
|
||||||
|
|
||||||
async def mark_webhook_sent(payment_hash: str, status: int) -> None:
|
async def mark_webhook_sent(payment_hash: str, status: int) -> None:
|
||||||
|
|||||||
@@ -557,8 +557,11 @@ async def m023_add_column_column_to_apipayments(db):
|
|||||||
"""
|
"""
|
||||||
renames hash to payment_hash and drops unused index
|
renames hash to payment_hash and drops unused index
|
||||||
"""
|
"""
|
||||||
await db.execute("ALTER TABLE apipayments DROP COLUMN pending")
|
|
||||||
await db.execute("DROP INDEX by_hash")
|
await db.execute("DROP INDEX by_hash")
|
||||||
await db.execute("ALTER TABLE apipayments RENAME COLUMN hash TO payment_hash")
|
await db.execute("ALTER TABLE apipayments RENAME COLUMN hash TO payment_hash")
|
||||||
await db.execute("ALTER TABLE apipayments RENAME COLUMN wallet TO wallet_id")
|
await db.execute("ALTER TABLE apipayments RENAME COLUMN wallet TO wallet_id")
|
||||||
await db.execute("ALTER TABLE accounts RENAME COLUMN pass TO password_hash")
|
await db.execute("ALTER TABLE accounts RENAME COLUMN pass TO password_hash")
|
||||||
|
|
||||||
|
|
||||||
|
async def m023_drop_pending(db):
|
||||||
|
await db.execute("ALTER TABLE apipayments DROP COLUMN pending")
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ from lnbits.wallets.base import (
|
|||||||
|
|
||||||
from .crud import (
|
from .crud import (
|
||||||
check_internal,
|
check_internal,
|
||||||
check_internal_pending,
|
check_internal_status,
|
||||||
create_account,
|
create_account,
|
||||||
create_admin_settings,
|
create_admin_settings,
|
||||||
create_payment,
|
create_payment,
|
||||||
@@ -243,7 +243,7 @@ async def pay_invoice(
|
|||||||
|
|
||||||
# we check if an internal invoice exists that has already been paid
|
# we check if an internal invoice exists that has already been paid
|
||||||
# (not pending anymore)
|
# (not pending anymore)
|
||||||
if not await check_internal_pending(invoice.payment_hash, conn=conn):
|
if await check_internal_status(invoice.payment_hash, conn=conn):
|
||||||
raise PaymentError("Internal invoice already paid.", status="failed")
|
raise PaymentError("Internal invoice already paid.", status="failed")
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
Reference in New Issue
Block a user