diff --git a/cashu/mint/router.py b/cashu/mint/router.py index 55c31322..fd6d7626 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -16,6 +16,8 @@ PostCheckStateResponse, PostDlcRegistrationRequest, PostDlcRegistrationResponse, + PostDlcSettleRequest, + PostDlcSettleResponse, PostMeltQuoteRequest, PostMeltQuoteResponse, PostMeltRequest, @@ -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)