Ver código fonte

Fix dleq logging (#670)

* fix: dleq logging

* feat: log wallet auth for request
thesimplekid 1 mês atrás
pai
commit
b3ae76d6c7

+ 1 - 1
crates/cashu/src/nuts/auth/nut22.rs

@@ -194,7 +194,7 @@ impl TryFrom<Proof> for AuthProof {
             keyset_id: value.keyset_id,
             keyset_id: value.keyset_id,
             secret: value.secret,
             secret: value.secret,
             c: value.c,
             c: value.c,
-            dleq: value.dleq.ok_or({
+            dleq: value.dleq.ok_or_else(|| {
                 tracing::warn!("Dleq proof not included in auth");
                 tracing::warn!("Dleq proof not included in auth");
                 Error::DleqProofNotIncluded
                 Error::DleqProofNotIncluded
             })?,
             })?,

+ 11 - 5
crates/cdk/src/wallet/auth/auth_wallet.rs

@@ -296,12 +296,18 @@ impl AuthWallet {
     ) -> Result<Option<AuthToken>, Error> {
     ) -> Result<Option<AuthToken>, Error> {
         match self.is_protected(method).await {
         match self.is_protected(method).await {
             Some(auth) => match auth {
             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 => {
                 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))
                     Ok(Some(proof))
                 }
                 }