NUT-06: Mint contact info (#585)

* Implement NUT-06 change: https://github.com/cashubtc/nuts/pull/117

* wallet deserialize

* ignore contact info for deprecated v0 response
This commit is contained in:
callebtc
2024-07-15 14:11:54 +02:00
committed by GitHub
parent f32099bce7
commit 21f339ca2b
4 changed files with 15 additions and 7 deletions

View File

@@ -25,13 +25,18 @@ class MintMeltMethodSetting(BaseModel):
max_amount: Optional[int] = None
class MintInfoContact(BaseModel):
method: str
info: str
class GetInfoResponse(BaseModel):
name: Optional[str] = None
pubkey: Optional[str] = None
version: Optional[str] = None
description: Optional[str] = None
description_long: Optional[str] = None
contact: Optional[List[List[str]]] = None
contact: Optional[List[MintInfoContact]] = None
motd: Optional[str] = None
nuts: Optional[Dict[int, Any]] = None

View File

@@ -10,6 +10,7 @@ from ..core.models import (
KeysetsResponseKeyset,
KeysResponse,
KeysResponseKeyset,
MintInfoContact,
PostCheckStateRequest,
PostCheckStateResponse,
PostMeltQuoteRequest,
@@ -41,13 +42,16 @@ router: APIRouter = APIRouter()
async def info() -> GetInfoResponse:
logger.trace("> GET /v1/info")
mint_features = ledger.mint_features()
contact_info = [
MintInfoContact(method=m, info=i) for m, i in settings.mint_info_contact
]
return GetInfoResponse(
name=settings.mint_info_name,
pubkey=ledger.pubkey.serialize().hex() if ledger.pubkey else None,
version=f"Nutshell/{settings.version}",
description=settings.mint_info_description,
description_long=settings.mint_info_description_long,
contact=settings.mint_info_contact,
contact=contact_info,
nuts=mint_features,
motd=settings.mint_info_motd,
)

View File

@@ -2,10 +2,9 @@ from typing import Any, Dict, List, Optional
from pydantic import BaseModel
from cashu.core.nuts import MPP_NUT, WEBSOCKETS_NUT
from ..core.base import Method, Unit
from ..core.models import Nut15MppSupport
from ..core.models import MintInfoContact, Nut15MppSupport
from ..core.nuts import MPP_NUT, WEBSOCKETS_NUT
class MintInfo(BaseModel):
@@ -14,7 +13,7 @@ class MintInfo(BaseModel):
version: Optional[str]
description: Optional[str]
description_long: Optional[str]
contact: Optional[List[List[str]]]
contact: Optional[List[MintInfoContact]]
motd: Optional[str]
nuts: Optional[Dict[int, Any]]

View File

@@ -136,7 +136,7 @@ class LedgerAPIDeprecated(SupportsHttpxClient, SupportsMintURL):
GetInfoResponse_deprecated.parse_obj(data)
)
mint_info = GetInfoResponse(
**mint_info_deprecated.dict(exclude={"parameter", "nuts"})
**mint_info_deprecated.dict(exclude={"parameter", "nuts", "contact"})
)
return mint_info