123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //! 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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let combined = format!("{}/{}", self.name, self.version);
- serializer.serialize_str(&combined)
- }
- }
- impl<'de> Deserialize<'de> for MintVersion {
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
- 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<String>,
- /// hex pubkey of the mint
- #[serde(skip_serializing_if = "Option::is_none")]
- pub pubkey: Option<PublicKey>,
- /// implementation name and the version running
- #[serde(skip_serializing_if = "Option::is_none")]
- pub version: Option<MintVersion>,
- /// short description of the mint
- #[serde(skip_serializing_if = "Option::is_none")]
- pub description: Option<String>,
- /// long description
- #[serde(skip_serializing_if = "Option::is_none")]
- pub description_long: Option<String>,
- /// contact methods to reach the mint operator
- #[serde(skip_serializing_if = "Option::is_none")]
- pub contact: Option<Vec<Vec<String>>>,
- /// shows which NUTs the mint supports
- #[serde(skip_serializing_if = "Vec::is_empty")]
- pub nuts: Vec<String>,
- /// message of the day that the wallet must display to the user
- #[serde(skip_serializing_if = "Option::is_none")]
- pub motd: Option<String>,
- }
|