mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-10 12:32:34 +02:00
feat: only check the current page (#3015)
This commit is contained in:
@@ -178,13 +178,20 @@ async def update_pending_payments(wallet_id: str):
|
|||||||
exclude_uncheckable=True,
|
exclude_uncheckable=True,
|
||||||
)
|
)
|
||||||
for payment in pending_payments:
|
for payment in pending_payments:
|
||||||
status = await payment.check_status()
|
await update_pending_payment(payment)
|
||||||
if status.failed:
|
|
||||||
payment.status = PaymentState.FAILED
|
|
||||||
await update_payment(payment)
|
async def update_pending_payment(payment: Payment) -> bool:
|
||||||
elif status.success:
|
status = await payment.check_status()
|
||||||
payment.status = PaymentState.SUCCESS
|
if status.failed:
|
||||||
await update_payment(payment)
|
payment.status = PaymentState.FAILED
|
||||||
|
await update_payment(payment)
|
||||||
|
return True
|
||||||
|
if status.success:
|
||||||
|
payment.status = PaymentState.SUCCESS
|
||||||
|
await update_payment(payment)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def fee_reserve_total(amount_msat: int, internal: bool = False) -> int:
|
def fee_reserve_total(amount_msat: int, internal: bool = False) -> int:
|
||||||
|
@@ -37,7 +37,10 @@ from lnbits.core.models import (
|
|||||||
Wallet,
|
Wallet,
|
||||||
)
|
)
|
||||||
from lnbits.core.models.users import User
|
from lnbits.core.models.users import User
|
||||||
from lnbits.core.services.payments import get_payments_daily_stats
|
from lnbits.core.services.payments import (
|
||||||
|
get_payments_daily_stats,
|
||||||
|
update_pending_payment,
|
||||||
|
)
|
||||||
from lnbits.db import Filters, Page
|
from lnbits.db import Filters, Page
|
||||||
from lnbits.decorators import (
|
from lnbits.decorators import (
|
||||||
WalletTypeInfo,
|
WalletTypeInfo,
|
||||||
@@ -180,11 +183,14 @@ async def api_payments_paginated(
|
|||||||
key_info: WalletTypeInfo = Depends(require_invoice_key),
|
key_info: WalletTypeInfo = Depends(require_invoice_key),
|
||||||
filters: Filters = Depends(parse_filters(PaymentFilters)),
|
filters: Filters = Depends(parse_filters(PaymentFilters)),
|
||||||
):
|
):
|
||||||
await update_pending_payments(key_info.wallet.id)
|
|
||||||
page = await get_payments_paginated(
|
page = await get_payments_paginated(
|
||||||
wallet_id=key_info.wallet.id,
|
wallet_id=key_info.wallet.id,
|
||||||
filters=filters,
|
filters=filters,
|
||||||
)
|
)
|
||||||
|
for payment in page.data:
|
||||||
|
if payment.pending:
|
||||||
|
await update_pending_payment(payment)
|
||||||
|
|
||||||
return page
|
return page
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user