Browse Source

chore: clippy

thesimplekid 1 year ago
parent
commit
60d3fd011e

+ 3 - 1
crates/cashu-sdk/Cargo.toml

@@ -14,9 +14,11 @@ default = ["mint", "wallet", "all-nuts", "redb"]
 mint = ["cashu/mint"]
 wallet = ["cashu/wallet", "dep:minreq", "dep:once_cell"]
 gloo = ["dep:gloo"]
-all-nuts = ["nut07", "nut08"]
+all-nuts = ["nut07", "nut08", "nut10", "nut11"]
 nut07 = ["cashu/nut07"]
 nut08 = ["cashu/nut08"]
+nut10 = ["cashu/nut10"]
+nut11 = ["cashu/nut11"]
 redb = ["dep:redb"]
 
 

+ 2 - 2
crates/cashu/src/dhke.rs

@@ -107,7 +107,7 @@ mod wallet {
             let proof = Proof::new(
                 promise.amount,
                 promise.keyset_id,
-                secrets[i].clone().try_into().unwrap(),
+                secrets[i].clone(),
                 unblinded_signature,
             );
 
@@ -127,7 +127,7 @@ mod mint {
 
     use super::hash_to_curve;
     use crate::error;
-    use crate::secret::Secret;
+
     /// Sign Blinded Message (Step2 bob)
     pub fn sign_message(
         a: SecretKey,

+ 2 - 2
crates/cashu/src/nuts/nut01.rs

@@ -49,12 +49,12 @@ impl TryFrom<&PublicKey> for VerifyingKey {
         let bytes = value.0.to_sec1_bytes();
 
         let bytes = if bytes.len().eq(&33) {
-            bytes.into_iter().skip(1).cloned().collect()
+            bytes.iter().skip(1).cloned().collect()
         } else {
             bytes.to_vec()
         };
 
-        Ok(VerifyingKey::from_bytes(&bytes).map_err(|_| Error::Key)?)
+        VerifyingKey::from_bytes(&bytes).map_err(|_| Error::Key)
     }
 }
 

+ 6 - 13
crates/cashu/src/nuts/nut11.rs

@@ -53,7 +53,7 @@ impl Proof {
         Proof {
             amount,
             keyset_id,
-            secret: secret.try_into().unwrap(),
+            secret,
             c,
             witness: Signatures::default(),
         }
@@ -152,14 +152,9 @@ impl TryFrom<Secret> for P2PKConditions {
 
         let mut pubkeys: Vec<PublicKey> = vec![];
 
-        if let Some(tag) = tags.get(&TagKind::Pubkeys) {
-            match tag {
-                Tag::PubKeys(keys) => {
-                    let mut keys = keys.clone();
-                    pubkeys.append(&mut keys);
-                }
-                _ => (),
-            }
+        if let Some(Tag::PubKeys(keys)) = tags.get(&TagKind::Pubkeys) {
+            let mut keys = keys.clone();
+            pubkeys.append(&mut keys);
         }
 
         let data_pubkey = PublicKey::from_hex(secret.secret_data.data)?;
@@ -412,8 +407,7 @@ where
                     let pubkeys = tag
                         .iter()
                         .skip(1)
-                        .map(|p| PublicKey::from_hex(p.as_ref().to_string()))
-                        .flatten()
+                        .flat_map(|p| PublicKey::from_hex(p.as_ref().to_string()))
                         .collect();
 
                     Ok(Self::Refund(pubkeys))
@@ -422,8 +416,7 @@ where
                     let pubkeys = tag
                         .iter()
                         .skip(1)
-                        .map(|p| PublicKey::from_hex(p.as_ref().to_string()))
-                        .flatten()
+                        .flat_map(|p| PublicKey::from_hex(p.as_ref().to_string()))
                         .collect();
 
                     Ok(Self::PubKeys(pubkeys))