//! Mint Information // https://github.com/cashubtc/nuts/blob/main/09.md use serde::{Deserialize, Deserializer, Serialize, Serializer}; use super::nut01::PublicKey; /// Mint Version #[derive(Debug, Clone, PartialEq, Eq)] pub struct MintVersion { pub name: String, pub version: String, } impl Serialize for MintVersion { fn serialize(&self, serializer: S) -> Result where S: Serializer, { let combined = format!("{}/{}", self.name, self.version); serializer.serialize_str(&combined) } } impl<'de> Deserialize<'de> for MintVersion { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let combined = String::deserialize(deserializer)?; let parts: Vec<&str> = combined.split('/').collect(); if parts.len() != 2 { return Err(serde::de::Error::custom("Invalid input string")); } Ok(MintVersion { name: parts[0].to_string(), version: parts[1].to_string(), }) } } /// Mint Info [NIP-09] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct MintInfo { /// name of the mint and should be recognizable #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, /// hex pubkey of the mint #[serde(skip_serializing_if = "Option::is_none")] pub pubkey: Option, /// implementation name and the version running #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, /// short description of the mint #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// long description #[serde(skip_serializing_if = "Option::is_none")] pub description_long: Option, /// contact methods to reach the mint operator #[serde(skip_serializing_if = "Option::is_none")] pub contact: Option>>, /// shows which NUTs the mint supports #[serde(skip_serializing_if = "Vec::is_empty")] pub nuts: Vec, /// message of the day that the wallet must display to the user #[serde(skip_serializing_if = "Option::is_none")] pub motd: Option, }