mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-31 16:08:42 +02:00
fixup!
This commit is contained in:
parent
3dc906a70b
commit
7c19dfbc83
@ -992,23 +992,22 @@ async def check_internal(
|
||||
return row["checking_id"]
|
||||
|
||||
|
||||
async def check_internal_pending(
|
||||
async def check_internal_status(
|
||||
payment_hash: str, conn: Optional[Connection] = None
|
||||
) -> bool:
|
||||
"""
|
||||
Returns False if the internal payment is not pending anymore
|
||||
(and thus paid), otherwise True
|
||||
Returns True if the internal payment was successful
|
||||
"""
|
||||
row: dict = await (conn or db).fetchone(
|
||||
"""
|
||||
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:
|
||||
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:
|
||||
|
@ -557,8 +557,11 @@ async def m023_add_column_column_to_apipayments(db):
|
||||
"""
|
||||
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("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 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 (
|
||||
check_internal,
|
||||
check_internal_pending,
|
||||
check_internal_status,
|
||||
create_account,
|
||||
create_admin_settings,
|
||||
create_payment,
|
||||
@ -242,7 +242,7 @@ async def pay_invoice(
|
||||
|
||||
# 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 await check_internal_status(invoice.payment_hash, conn=conn):
|
||||
raise PaymentError("Internal invoice already paid.", status="failed")
|
||||
|
||||
# check_internal() returns the checking_id of the invoice we're waiting for
|
||||
|
Loading…
x
Reference in New Issue
Block a user