diff --git a/crates/cdk-cli/src/main.rs b/crates/cdk-cli/src/main.rs index 71f34c0d..8838155e 100644 --- a/crates/cdk-cli/src/main.rs +++ b/crates/cdk-cli/src/main.rs @@ -66,7 +66,7 @@ enum Commands { #[tokio::main] async fn main() -> Result<()> { tracing_subscriber::fmt() - .with_max_level(tracing::Level::WARN) + .with_max_level(tracing::Level::DEBUG) .init(); // Parse input diff --git a/crates/cdk-mintd/src/main.rs b/crates/cdk-mintd/src/main.rs index 515c907c..76e08987 100644 --- a/crates/cdk-mintd/src/main.rs +++ b/crates/cdk-mintd/src/main.rs @@ -142,8 +142,8 @@ async fn main() -> anyhow::Result<()> { Vec, ) = ln_backends.iter().fold( ( - nut04::Settings::default(), - nut05::Settings::default(), + nut04::Settings::new(vec![], false), + nut05::Settings::new(vec![], false), Vec::new(), ), |(mut nut_04, mut nut_05, mut mpp), (key, ln)| { diff --git a/crates/cdk/src/nuts/nut04.rs b/crates/cdk/src/nuts/nut04.rs index a522186b..4ce0da75 100644 --- a/crates/cdk/src/nuts/nut04.rs +++ b/crates/cdk/src/nuts/nut04.rs @@ -217,6 +217,13 @@ pub struct Settings { pub disabled: bool, } +impl Settings { + /// Create new [`Settings`] + pub fn new(methods: Vec, disabled: bool) -> Self { + Self { methods, disabled } + } +} + impl Default for Settings { fn default() -> Self { let bolt11_mint = MintMethodSettings { diff --git a/crates/cdk/src/nuts/nut05.rs b/crates/cdk/src/nuts/nut05.rs index 1f3adca9..6b6bc7df 100644 --- a/crates/cdk/src/nuts/nut05.rs +++ b/crates/cdk/src/nuts/nut05.rs @@ -252,6 +252,13 @@ pub struct MeltMethodSettings { pub max_amount: Option, } +impl Settings { + /// Create new [`Settings`] + pub fn new(methods: Vec, disabled: bool) -> Self { + Self { methods, disabled } + } +} + /// Melt Settings #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Settings { diff --git a/crates/cdk/src/nuts/nut06.rs b/crates/cdk/src/nuts/nut06.rs index d50b86fc..6e594d90 100644 --- a/crates/cdk/src/nuts/nut06.rs +++ b/crates/cdk/src/nuts/nut06.rs @@ -2,9 +2,6 @@ //! //! -use std::fmt; - -use serde::de::{self, SeqAccess, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use super::nut01::PublicKey; @@ -73,7 +70,6 @@ pub struct MintInfo { pub description_long: Option, /// Contact info #[serde(skip_serializing_if = "Option::is_none")] - #[serde(deserialize_with = "deserialize_contact_info")] pub contact: Option>, /// shows which NUTs the mint supports pub nuts: Nuts, @@ -336,61 +332,6 @@ impl ContactInfo { } } -fn deserialize_contact_info<'de, D>(deserializer: D) -> Result>, D::Error> -where - D: Deserializer<'de>, -{ - struct ContactInfoVisitor; - - impl<'de> Visitor<'de> for ContactInfoVisitor { - type Value = Option>; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("a list of ContactInfo or a list of lists of strings") - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: SeqAccess<'de>, - { - let mut contacts = Vec::new(); - - while let Some(value) = seq.next_element::()? { - if value.is_object() { - // Deserialize as ContactInfo - let contact: ContactInfo = - serde_json::from_value(value).map_err(de::Error::custom)?; - contacts.push(contact); - } else if value.is_array() { - // Deserialize as Vec - let vec = value - .as_array() - .ok_or_else(|| de::Error::custom("expected a list of strings"))?; - - if vec.len() == 2 { - let method = vec[0] - .as_str() - .ok_or_else(|| de::Error::custom("expected a string"))? - .to_string(); - let info = vec[1] - .as_str() - .ok_or_else(|| de::Error::custom("expected a string"))? - .to_string(); - contacts.push(ContactInfo { method, info }); - } else { - return Err(de::Error::custom("expected a list of two strings")); - } - } else { - return Err(de::Error::custom("expected an object or a list of strings")); - } - } - Ok(Some(contacts)) - } - } - - deserializer.deserialize_seq(ContactInfoVisitor) -} - #[cfg(test)] mod tests { diff --git a/crates/cdk/src/wallet/client.rs b/crates/cdk/src/wallet/client.rs index 3fddcc8e..18f5c7fd 100644 --- a/crates/cdk/src/wallet/client.rs +++ b/crates/cdk/src/wallet/client.rs @@ -294,7 +294,10 @@ impl HttpClient { match serde_json::from_value::(res.clone()) { Ok(melt_quote_response) => Ok(melt_quote_response), - Err(_) => Err(ErrorResponse::from_value(res)?.into()), + Err(err) => { + tracing::error!("Could not get mint info: {}", err); + Err(ErrorResponse::from_value(res)?.into()) + } } }