From b3ae76d6c77a6a1523af3cf97ebc3ddd81a8e4a3 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Mon, 24 Mar 2025 12:50:54 +0000 Subject: [PATCH] Fix dleq logging (#670) * fix: dleq logging * feat: log wallet auth for request --- crates/cashu/src/nuts/auth/nut22.rs | 2 +- crates/cdk/src/wallet/auth/auth_wallet.rs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/cashu/src/nuts/auth/nut22.rs b/crates/cashu/src/nuts/auth/nut22.rs index 2677cd44..4c15fc03 100644 --- a/crates/cashu/src/nuts/auth/nut22.rs +++ b/crates/cashu/src/nuts/auth/nut22.rs @@ -194,7 +194,7 @@ impl TryFrom for AuthProof { keyset_id: value.keyset_id, secret: value.secret, c: value.c, - dleq: value.dleq.ok_or({ + dleq: value.dleq.ok_or_else(|| { tracing::warn!("Dleq proof not included in auth"); Error::DleqProofNotIncluded })?, diff --git a/crates/cdk/src/wallet/auth/auth_wallet.rs b/crates/cdk/src/wallet/auth/auth_wallet.rs index 778e9006..c9ada6fd 100644 --- a/crates/cdk/src/wallet/auth/auth_wallet.rs +++ b/crates/cdk/src/wallet/auth/auth_wallet.rs @@ -296,12 +296,18 @@ impl AuthWallet { ) -> Result, Error> { match self.is_protected(method).await { Some(auth) => match auth { - AuthRequired::Clear => self.client.get_auth_token().await.map(Some), + AuthRequired::Clear => { + tracing::trace!("Clear auth needed for request."); + self.client.get_auth_token().await.map(Some) + } AuthRequired::Blind => { - let proof = self - .get_blind_auth_token() - .await? - .ok_or(Error::InsufficientBlindAuthTokens)?; + tracing::trace!("Blind auth needed for request getting Auth proof."); + let proof = self.get_blind_auth_token().await?.ok_or_else(|| { + tracing::debug!( + "Insufficient blind auth proofs in wallet. Must mint bats." + ); + Error::InsufficientBlindAuthTokens + })?; Ok(Some(proof)) }