Skip to content

Commit

Permalink
Merge pull request #5 from gudnuf/dlc-fix-router
Browse files Browse the repository at this point in the history
Fix router paths and add `POST /v1/dlc/settle`
  • Loading branch information
lollerfirst authored Sep 13, 2024
2 parents 9c5bf34 + 62145e2 commit a5f7590
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions cashu/mint/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
PostCheckStateResponse,
PostDlcRegistrationRequest,
PostDlcRegistrationResponse,
PostDlcSettleRequest,
PostDlcSettleResponse,
PostMeltQuoteRequest,
PostMeltQuoteResponse,
PostMeltRequest,
Expand Down Expand Up @@ -379,31 +381,50 @@ async def restore(payload: PostRestoreRequest) -> PostRestoreResponse:
outputs, signatures = await ledger.restore(payload.outputs)
return PostRestoreResponse(outputs=outputs, signatures=signatures)


@router.post(
"v1/dlc/fund",
"/v1/dlc/fund",
name="Fund",
summary="Register and fund a DLC batch",
response_model=PostDlcRegistrationResponse,
response_description=(
"Two lists describing which DLC were registered and which encountered errors respectively."
)
),
)
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
async def dlc_fund(request: Request, payload: PostDlcRegistrationRequest) -> PostDlcRegistrationResponse:
async def dlc_fund(
request: Request, payload: PostDlcRegistrationRequest
) -> PostDlcRegistrationResponse:
logger.trace(f"> POST /v1/dlc/fund: {payload}")
assert len(payload.registrations) > 0, "No registrations provided"
return await ledger.register_dlc(payload)


@router.get(
"v1/dlc/status/{dlc_root}",
"/v1/dlc/status/{dlc_root}",
name="",
summary="Register a DLC batch",
response_model=GetDlcStatusResponse,
response_description=(
"Two lists describing which DLC were registered and which encountered errors respectively."
)
),
)
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
async def dlc_status(request: Request, dlc_root: str) -> GetDlcStatusResponse:
logger.trace(f"> GET /v1/dlc/status/{dlc_root}")
return await ledger.status_dlc(dlc_root)


@router.post(
"/v1/dlc/settle",
name="Settle",
summary="Prove DLC outcomes",
response_model=PostDlcSettleResponse,
response_description="Two lists describing which DLC were settled and which encountered errors respectively.",
)
@limiter.limit(f"{settings.mint_transaction_rate_limit_per_minute}/minute")
async def dlc_settle(
request: Request, payload: PostDlcSettleRequest
) -> PostDlcSettleResponse:
logger.trace(f"> POST /v1/dlc/settle: {payload}")
return await ledger.settle_dlc(payload)

0 comments on commit a5f7590

Please sign in to comment.