Skip to content

Commit

Permalink
NUT-06: Mint contact info (#585)
Browse files Browse the repository at this point in the history
* Implement NUT-06 change: cashubtc/nuts#117

* wallet deserialize

* ignore contact info for deprecated v0 response
  • Loading branch information
callebtc authored Jul 15, 2024
1 parent f32099b commit 21f339c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 6 additions & 1 deletion cashu/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion cashu/mint/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
KeysetsResponseKeyset,
KeysResponse,
KeysResponseKeyset,
MintInfoContact,
PostCheckStateRequest,
PostCheckStateResponse,
PostMeltQuoteRequest,
Expand Down Expand Up @@ -41,13 +42,16 @@
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,
)
Expand Down
7 changes: 3 additions & 4 deletions cashu/wallet/mint_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

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):
Expand All @@ -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]]

Expand Down
2 changes: 1 addition & 1 deletion cashu/wallet/wallet_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def _get_info_deprecated(self) -> GetInfoResponse:
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

Expand Down

0 comments on commit 21f339c

Please sign in to comment.