Skip to content

Commit

Permalink
Merge pull request #592 from thesimplekid/debug_print_of_i
Browse files Browse the repository at this point in the history
feat: debug print to hide seed and print version
  • Loading branch information
thesimplekid authored Feb 9, 2025
2 parents fedd4b9 + 3a4c363 commit 3775d7d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
8 changes: 7 additions & 1 deletion crates/cashu/src/nuts/nut02.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<String> for Id {
type Error = Error;

Expand Down
4 changes: 1 addition & 3 deletions crates/cdk-integration-tests/tests/fake_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions crates/cdk-mintd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 19 additions & 1 deletion crates/cdk-mintd/src/config.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -23,6 +24,23 @@ pub struct Info {
pub enable_swagger_ui: Option<bool>,
}

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!("<hashed: {}>", 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 {
Expand Down

0 comments on commit 3775d7d

Please sign in to comment.