mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 12:28:22 +00:00
fix: renew refund lease on the request session
This commit is contained in:
+9
-10
@@ -144,16 +144,15 @@ async def _close(
|
|||||||
return bool(result.rowcount)
|
return bool(result.rowcount)
|
||||||
|
|
||||||
|
|
||||||
async def renew_lease(refund: Refund) -> None:
|
async def renew_lease(session: AsyncSession, refund: Refund) -> None:
|
||||||
"""Push the reconciler lease forward before a slow mint step."""
|
"""Push the reconciler lease forward before a slow mint step."""
|
||||||
async with create_session() as session:
|
await session.exec( # type: ignore[call-overload]
|
||||||
await session.exec( # type: ignore[call-overload]
|
update(Refund)
|
||||||
update(Refund)
|
.where(col(Refund.id) == refund.id)
|
||||||
.where(col(Refund.id) == refund.id)
|
.where(col(Refund.status).in_(REFUND_OPEN_STATUSES))
|
||||||
.where(col(Refund.status).in_(REFUND_OPEN_STATUSES))
|
.values(claimed_at=int(time.time()))
|
||||||
.values(claimed_at=int(time.time()))
|
)
|
||||||
)
|
await session.commit()
|
||||||
await session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
async def record_quote(refund: Refund, quote_id: str, mint_url: str) -> None:
|
async def record_quote(refund: Refund, quote_id: str, mint_url: str) -> None:
|
||||||
@@ -349,7 +348,7 @@ async def _pay_lightning(session: AsyncSession, refund: Refund) -> bool:
|
|||||||
|
|
||||||
async def _pay_cashu(session: AsyncSession, refund: Refund) -> bool:
|
async def _pay_cashu(session: AsyncSession, refund: Refund) -> bool:
|
||||||
amount = amount_in_unit(refund.amount_msats, refund.unit)
|
amount = amount_in_unit(refund.amount_msats, refund.unit)
|
||||||
await renew_lease(refund)
|
await renew_lease(session, refund)
|
||||||
token = await send_token(amount, refund.unit, refund.mint_url)
|
token = await send_token(amount, refund.unit, refund.mint_url)
|
||||||
# From here the token is bearer money: keep it on the claim so a failed
|
# From here the token is bearer money: keep it on the claim so a failed
|
||||||
# settle withholds the balance instead of restoring it.
|
# settle withholds the balance instead of restoring it.
|
||||||
|
|||||||
Reference in New Issue
Block a user