diff --git a/crates/cashu/src/nuts/nut02.rs b/crates/cashu/src/nuts/nut02.rs index 620989f2..8c79cc99 100644 --- a/crates/cashu/src/nuts/nut02.rs +++ b/crates/cashu/src/nuts/nut02.rs @@ -86,7 +86,7 @@ impl fmt::Display for KeySetVersion { /// anyone who knows the set of public keys of a mint. The keyset ID **CAN** /// be stored in a Cashu token such that the token can be used to identify /// which mint or keyset it was generated from. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(into = "String", try_from = "String")] #[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = String))] pub struct Id { @@ -138,6 +138,12 @@ impl fmt::Display for Id { } } +impl fmt::Debug for Id { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&format!("{}{}", self.version, hex::encode(self.id))) + } +} + impl TryFrom for Id { type Error = Error; diff --git a/crates/cdk-integration-tests/tests/fake_wallet.rs b/crates/cdk-integration-tests/tests/fake_wallet.rs index b50a62e4..59370a16 100644 --- a/crates/cdk-integration-tests/tests/fake_wallet.rs +++ b/crates/cdk-integration-tests/tests/fake_wallet.rs @@ -867,9 +867,7 @@ async fn test_fake_mint_input_output_mismatch() -> Result<()> { match response { Err(err) => match err { cdk::Error::UnitMismatch => (), - err => { - bail!("Wrong error returned: {}", err); - } + err => bail!("Wrong error returned: {}", err), }, Ok(_) => { bail!("Should not have allowed to mint with multiple units"); diff --git a/crates/cdk-mintd/Cargo.toml b/crates/cdk-mintd/Cargo.toml index ede9a749..f3718b8f 100644 --- a/crates/cdk-mintd/Cargo.toml +++ b/crates/cdk-mintd/Cargo.toml @@ -36,6 +36,12 @@ cdk-axum = { path = "../cdk-axum", version = "0.7.0", default-features = false } cdk-mint-rpc = { path = "../cdk-mint-rpc", version = "0.7.0", default-features = false, optional = true } config = { version = "0.13.3", features = ["toml"] } clap = { version = "~4.0.32", features = ["derive"] } +bitcoin = { version = "0.32.2", features = [ + "base64", + "serde", + "rand", + "rand-std", +] } tokio = { version = "1", default-features = false } tracing = { version = "0.1", default-features = false, features = [ "attributes", diff --git a/crates/cdk-mintd/src/config.rs b/crates/cdk-mintd/src/config.rs index a7ef3254..d9c1178b 100644 --- a/crates/cdk-mintd/src/config.rs +++ b/crates/cdk-mintd/src/config.rs @@ -1,12 +1,13 @@ use std::path::PathBuf; +use bitcoin::hashes::{sha256, Hash}; use cdk::nuts::{CurrencyUnit, PublicKey}; use cdk::Amount; use cdk_axum::cache; use config::{Config, ConfigError, File}; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize, Default)] +#[derive(Clone, Serialize, Deserialize, Default)] pub struct Info { pub url: String, pub listen_host: String, @@ -23,6 +24,23 @@ pub struct Info { pub enable_swagger_ui: Option, } +impl std::fmt::Debug for Info { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mnemonic_hash = sha256::Hash::from_slice(&self.mnemonic.clone().into_bytes()) + .map_err(|_| std::fmt::Error)?; + + f.debug_struct("Info") + .field("url", &self.url) + .field("listen_host", &self.listen_host) + .field("listen_port", &self.listen_port) + .field("mnemonic", &format!("", mnemonic_hash)) + .field("input_fee_ppk", &self.input_fee_ppk) + .field("http_cache", &self.http_cache) + .field("enable_swagger_ui", &self.enable_swagger_ui) + .finish() + } +} + #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)] #[serde(rename_all = "lowercase")] pub enum LnBackend {