From accfdfec8e4e787311c5bd16907ebb5c920a3d7c Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 4 Sep 2024 11:15:27 +0200 Subject: [PATCH] implement nut-06 time (#611) --- cashu/core/models.py | 1 + cashu/mint/router.py | 2 ++ cashu/wallet/cli/cli.py | 2 ++ cashu/wallet/mint_info.py | 1 + 4 files changed, 6 insertions(+) diff --git a/cashu/core/models.py b/cashu/core/models.py index 065c6a3..e4b1879 100644 --- a/cashu/core/models.py +++ b/cashu/core/models.py @@ -38,6 +38,7 @@ class GetInfoResponse(BaseModel): description_long: Optional[str] = None contact: Optional[List[MintInfoContact]] = None motd: Optional[str] = None + time: Optional[int] = None nuts: Optional[Dict[int, Any]] = None def supports(self, nut: int) -> Optional[bool]: diff --git a/cashu/mint/router.py b/cashu/mint/router.py index 56226f3..d3d9761 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -1,4 +1,5 @@ import asyncio +import time from fastapi import APIRouter, Request, WebSocket from loguru import logger @@ -56,6 +57,7 @@ async def info() -> GetInfoResponse: contact=contact_info, nuts=mint_features, motd=settings.mint_info_motd, + time=int(time.time()), ) diff --git a/cashu/wallet/cli/cli.py b/cashu/wallet/cli/cli.py index c9b81cc..59e8009 100644 --- a/cashu/wallet/cli/cli.py +++ b/cashu/wallet/cli/cli.py @@ -996,6 +996,8 @@ async def info(ctx: Context, mint: bool, mnemonic: bool): print(f" - Version: {mint_info['version']}") if mint_info.get("motd"): print(f" - Message of the day: {mint_info['motd']}") + if mint_info.get("time"): + print(f" - Server time: {mint_info['time']}") if mint_info.get("nuts"): print( " - Supported NUTS:" diff --git a/cashu/wallet/mint_info.py b/cashu/wallet/mint_info.py index 760f43c..37fe072 100644 --- a/cashu/wallet/mint_info.py +++ b/cashu/wallet/mint_info.py @@ -15,6 +15,7 @@ class MintInfo(BaseModel): description_long: Optional[str] contact: Optional[List[MintInfoContact]] motd: Optional[str] + time: Optional[int] nuts: Optional[Dict[int, Any]] def __str__(self):