Explorar el Código

chore: correct errors

thesimplekid hace 1 mes
padre
commit
4eb884d1e1

+ 1 - 0
crates/cashu/src/lib.rs

@@ -1,6 +1,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 pub mod amount;
 pub mod dhke;

+ 13 - 10
crates/cdk-axum/src/lib.rs

@@ -3,6 +3,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::sync::Arc;
 
@@ -242,16 +243,17 @@ async fn cors_middleware(
     // Handle preflight requests
     if req.method() == axum::http::Method::OPTIONS {
         let mut response = Response::new("".into());
-        response
-            .headers_mut()
-            .insert("Access-Control-Allow-Origin", "*".parse().unwrap());
+        response.headers_mut().insert(
+            "Access-Control-Allow-Origin",
+            "*".parse().expect("Valid header value"),
+        );
         response.headers_mut().insert(
             "Access-Control-Allow-Methods",
-            "GET, POST, OPTIONS".parse().unwrap(),
+            "GET, POST, OPTIONS".parse().expect("Valid header value"),
         );
         response.headers_mut().insert(
             "Access-Control-Allow-Headers",
-            allowed_headers.parse().unwrap(),
+            allowed_headers.parse().expect("Valid header value"),
         );
         return response;
     }
@@ -259,16 +261,17 @@ async fn cors_middleware(
     // Call the next handler
     let mut response = next.run(req).await;
 
-    response
-        .headers_mut()
-        .insert("Access-Control-Allow-Origin", "*".parse().unwrap());
+    response.headers_mut().insert(
+        "Access-Control-Allow-Origin",
+        "*".parse().expect("Valid header value"),
+    );
     response.headers_mut().insert(
         "Access-Control-Allow-Methods",
-        "GET, POST, OPTIONS".parse().unwrap(),
+        "GET, POST, OPTIONS".parse().expect("Valid header value"),
     );
     response.headers_mut().insert(
         "Access-Control-Allow-Headers",
-        allowed_headers.parse().unwrap(),
+        allowed_headers.parse().expect("Valid header value"),
     );
 
     response

+ 4 - 1
crates/cdk-cli/src/main.rs

@@ -1,3 +1,5 @@
+#![deny(clippy::unwrap_used)]
+
 use std::fs;
 use std::path::PathBuf;
 use std::str::FromStr;
@@ -126,7 +128,8 @@ async fn main() -> Result<()> {
     let work_dir = match &args.work_dir {
         Some(work_dir) => work_dir.clone(),
         None => {
-            let home_dir = home::home_dir().unwrap();
+            let home_dir = home::home_dir()
+                .ok_or_else(|| anyhow::anyhow!("Could not determine home directory"))?;
             home_dir.join(DEFAULT_WORK_DIR)
         }
     };

+ 4 - 1
crates/cdk-cli/src/sub_commands/burn.rs

@@ -18,7 +18,10 @@ pub async fn burn(
 
     match &sub_command_args.mint_url {
         Some(mint_url) => {
-            let wallet = multi_mint_wallet.get_wallet(mint_url).await.unwrap();
+            let wallet = multi_mint_wallet
+                .get_wallet(mint_url)
+                .await
+                .ok_or_else(|| anyhow::anyhow!("Wallet not found for mint: {}", mint_url))?;
             total_burnt = wallet.check_all_pending_proofs().await?;
         }
         None => {

+ 1 - 1
crates/cdk-cli/src/sub_commands/pay_request.rs

@@ -27,7 +27,7 @@ pub async fn pay_request(
 
             let mut user_input = String::new();
             let stdin = io::stdin();
-            io::stdout().flush().unwrap();
+            io::stdout().flush()?;
             stdin.read_line(&mut user_input)?;
 
             let amount: u64 = user_input.trim().parse()?;

+ 13 - 14
crates/cdk-cli/src/sub_commands/send.rs

@@ -133,8 +133,8 @@ pub async fn send(
                     sub_command_args
                         .pubkey
                         .iter()
-                        .map(|p| PublicKey::from_str(p).unwrap())
-                        .collect(),
+                        .map(|p| PublicKey::from_str(p))
+                        .collect::<Result<Vec<_>, _>>()?,
                 ),
             };
 
@@ -144,8 +144,8 @@ pub async fn send(
                     sub_command_args
                         .refund_keys
                         .iter()
-                        .map(|p| PublicKey::from_str(p).unwrap())
-                        .collect(),
+                        .map(|p| PublicKey::from_str(p))
+                        .collect::<Result<Vec<_>, _>>()?,
                 ),
             };
 
@@ -156,8 +156,7 @@ pub async fn send(
                 sub_command_args.required_sigs,
                 None,
                 None,
-            )
-            .unwrap();
+            )?;
 
             Some(SpendingConditions::new_htlc(
                 preimage.clone(),
@@ -171,8 +170,8 @@ pub async fn send(
                     sub_command_args
                         .pubkey
                         .iter()
-                        .map(|p| PublicKey::from_str(p).unwrap())
-                        .collect(),
+                        .map(|p| PublicKey::from_str(p))
+                        .collect::<Result<Vec<_>, _>>()?,
                 ),
             };
 
@@ -182,8 +181,8 @@ pub async fn send(
                     sub_command_args
                         .refund_keys
                         .iter()
-                        .map(|p| PublicKey::from_str(p).unwrap())
-                        .collect(),
+                        .map(|p| PublicKey::from_str(p))
+                        .collect::<Result<Vec<_>, _>>()?,
                 ),
             };
 
@@ -204,14 +203,14 @@ pub async fn send(
                 let pubkeys: Vec<PublicKey> = sub_command_args
                     .pubkey
                     .iter()
-                    .map(|p| PublicKey::from_str(p).unwrap())
-                    .collect();
+                    .map(|p| PublicKey::from_str(p))
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 let refund_keys: Vec<PublicKey> = sub_command_args
                     .refund_keys
                     .iter()
-                    .map(|p| PublicKey::from_str(p).unwrap())
-                    .collect();
+                    .map(|p| PublicKey::from_str(p))
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 let refund_keys = (!refund_keys.is_empty()).then_some(refund_keys);
 

+ 1 - 0
crates/cdk-cln/src/lib.rs

@@ -3,6 +3,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::cmp::max;
 use std::path::PathBuf;

+ 1 - 0
crates/cdk-common/src/lib.rs

@@ -7,6 +7,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 pub mod task;
 

+ 7 - 12
crates/cdk-fake-wallet/src/lib.rs

@@ -12,6 +12,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::cmp::max;
 use std::collections::{HashMap, HashSet, VecDeque};
@@ -280,7 +281,7 @@ impl SecondaryRepaymentQueue {
                     rng.fill(&mut random_bytes);
                     let timestamp = std::time::SystemTime::now()
                         .duration_since(std::time::UNIX_EPOCH)
-                        .unwrap()
+                        .expect("System time before UNIX_EPOCH")
                         .as_nanos() as u64;
 
                     // Create a unique hash combining the original payment identifier, timestamp, and random bytes
@@ -443,13 +444,7 @@ impl MintPayment for FakeWallet {
         &self,
     ) -> Result<Pin<Box<dyn Stream<Item = Event> + Send>>, Self::Err> {
         tracing::info!("Starting stream for fake invoices");
-        let receiver = self
-            .receiver
-            .lock()
-            .await
-            .take()
-            .ok_or(Error::NoReceiver)
-            .unwrap();
+        let receiver = self.receiver.lock().await.take().ok_or(Error::NoReceiver)?;
         let receiver_stream = ReceiverStream::new(receiver);
         Ok(Box::pin(receiver_stream.map(move |wait_response| {
             Event::PaymentReceived(wait_response)
@@ -671,7 +666,7 @@ impl MintPayment for FakeWallet {
                     None => offer_builder,
                 };
 
-                let offer = offer_builder.build().unwrap();
+                let offer = offer_builder.build().expect("Failed to build BOLT12 offer");
 
                 (
                     PaymentIdentifier::OfferId(offer.id().to_string()),
@@ -818,7 +813,7 @@ pub fn create_fake_invoice(amount_msat: u64, description: String) -> Bolt11Invoi
             0x3b, 0x2d, 0xb7, 0x34,
         ][..],
     )
-    .unwrap();
+    .expect("Valid 32-byte secret key");
 
     use bitcoin::secp256k1::rand::rngs::OsRng;
     use bitcoin::secp256k1::rand::Rng;
@@ -826,7 +821,7 @@ pub fn create_fake_invoice(amount_msat: u64, description: String) -> Bolt11Invoi
     let mut random_bytes = [0u8; 32];
     rng.fill(&mut random_bytes);
 
-    let payment_hash = sha256::Hash::from_slice(&random_bytes).unwrap();
+    let payment_hash = sha256::Hash::from_slice(&random_bytes).expect("Valid 32-byte hash input");
     let payment_secret = PaymentSecret([42u8; 32]);
 
     InvoiceBuilder::new(Currency::Bitcoin)
@@ -837,5 +832,5 @@ pub fn create_fake_invoice(amount_msat: u64, description: String) -> Bolt11Invoi
         .current_timestamp()
         .min_final_cltv_expiry_delta(144)
         .build_signed(|hash| Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key))
-        .unwrap()
+        .expect("Failed to build fake invoice")
 }

+ 1 - 0
crates/cdk-ffi/src/lib.rs

@@ -3,6 +3,7 @@
 //! UniFFI bindings for the CDK Wallet and related types.
 
 #![warn(clippy::unused_async)]
+#![deny(clippy::unwrap_used)]
 
 pub mod database;
 pub mod error;

+ 2 - 1
crates/cdk-ffi/src/multi_mint_wallet.rs

@@ -188,7 +188,8 @@ impl MultiMintWallet {
             // This is a best-effort operation
             cdk::mint_url::MintUrl::from_str(&url_str).unwrap_or_else(|_| {
                 // Last resort: create a dummy URL that won't match anything
-                cdk::mint_url::MintUrl::from_str("https://invalid.mint").unwrap()
+                cdk::mint_url::MintUrl::from_str("https://invalid.mint")
+                    .expect("Valid hardcoded URL")
             })
         });
         self.inner.remove_mint(&cdk_mint_url).await;

+ 2 - 2
crates/cdk-ffi/src/types/keys.rs

@@ -32,7 +32,7 @@ impl From<KeySetInfo> for cdk::nuts::KeySetInfo {
     fn from(keyset: KeySetInfo) -> Self {
         use std::str::FromStr;
         Self {
-            id: cdk::nuts::Id::from_str(&keyset.id).unwrap(),
+            id: cdk::nuts::Id::from_str(&keyset.id).expect("Invalid keyset ID"),
             unit: keyset.unit.into(),
             active: keyset.active,
             final_expiry: None,
@@ -253,6 +253,6 @@ impl From<cdk::nuts::Id> for Id {
 impl From<Id> for cdk::nuts::Id {
     fn from(id: Id) -> Self {
         use std::str::FromStr;
-        Self::from_str(&id.hex).unwrap()
+        Self::from_str(&id.hex).expect("Invalid ID hex")
     }
 }

+ 1 - 0
crates/cdk-ldk-node/src/lib.rs

@@ -3,6 +3,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::net::SocketAddr;
 use std::pin::Pin;

+ 22 - 22
crates/cdk-ldk-node/src/web/handlers/channels.rs

@@ -37,11 +37,11 @@ pub struct CloseChannelForm {
 
 pub async fn channels_page(State(_state): State<AppState>) -> Result<Response, StatusCode> {
     // Redirect to the balance page since channels are now part of the Lightning section
-    Ok(Response::builder()
+    Response::builder()
         .status(StatusCode::FOUND)
         .header("Location", "/balance")
         .body(Body::empty())
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 pub async fn open_channel_page(State(state): State<AppState>) -> Result<Html<String>, StatusCode> {
@@ -106,13 +106,13 @@ pub async fn post_open_channel(
                     a href="/channels/open" { button { "← Try Again" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Open Channel Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -126,13 +126,13 @@ pub async fn post_open_channel(
                     a href="/channels/open" { button { "← Try Again" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Open Channel Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -150,13 +150,13 @@ pub async fn post_open_channel(
                 a href="/channels/open" { button { "← Try Again" } }
             }
         };
-        return Ok(Response::builder()
+        return Response::builder()
             .status(StatusCode::INTERNAL_SERVER_ERROR)
             .header("content-type", "text/html")
             .body(Body::from(
                 layout_with_status("Open Channel Error", content, true).into_string(),
             ))
-            .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+            .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
     }
 
     // Then open the channel
@@ -209,12 +209,12 @@ pub async fn post_open_channel(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Open Channel Result", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 pub async fn close_channel_page(
@@ -374,13 +374,13 @@ pub async fn post_close_channel(
                     a href="/channels" { button { "← Back to Channels" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Close Channel Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -394,13 +394,13 @@ pub async fn post_close_channel(
                     a href="/channels" { button { "← Back to Channels" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Close Channel Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -446,12 +446,12 @@ pub async fn post_close_channel(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Close Channel Result", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 pub async fn post_force_close_channel(
@@ -477,13 +477,13 @@ pub async fn post_force_close_channel(
                     a href="/channels" { button { "← Back to Channels" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Force Close Channel Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -497,13 +497,13 @@ pub async fn post_force_close_channel(
                     a href="/channels" { button { "← Back to Channels" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Force Close Channel Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -551,10 +551,10 @@ pub async fn post_force_close_channel(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Force Close Channel Result", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }

+ 6 - 6
crates/cdk-ldk-node/src/web/handlers/invoices.rs

@@ -170,13 +170,13 @@ pub async fn post_create_bolt11(
                         a href="/invoices" { button { "← Try Again" } }
                     }
                 };
-                return Ok(Response::builder()
+                return Response::builder()
                     .status(StatusCode::BAD_REQUEST)
                     .header("content-type", "text/html")
                     .body(Body::from(
                         layout_with_status(" Error", content, true).into_string(),
                     ))
-                    .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                    .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
             }
         }
     };
@@ -235,12 +235,12 @@ pub async fn post_create_bolt11(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("BOLT11 Invoice Created", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 pub async fn post_create_bolt12(
@@ -322,10 +322,10 @@ pub async fn post_create_bolt12(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("BOLT12 Offer Created", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }

+ 12 - 12
crates/cdk-ldk-node/src/web/handlers/onchain.rs

@@ -230,11 +230,11 @@ pub async fn post_send_onchain(
     let encoded_form =
         serde_urlencoded::to_string(&form).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
 
-    Ok(Response::builder()
+    Response::builder()
         .status(StatusCode::FOUND)
         .header("Location", format!("/onchain/confirm?{}", encoded_form))
         .body(Body::empty())
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 pub async fn onchain_confirm_page(
@@ -258,13 +258,13 @@ pub async fn onchain_confirm_page(
                     a href="/onchain?action=send" { button { "← Back" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Send On-chain Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -284,13 +284,13 @@ pub async fn onchain_confirm_page(
                     a href="/onchain?action=send" { button { "← Back" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Send On-chain Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
         (amount, false)
     };
@@ -359,12 +359,12 @@ pub async fn onchain_confirm_page(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Confirm Transaction", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 async fn execute_onchain_transaction(
@@ -391,13 +391,13 @@ async fn execute_onchain_transaction(
                     a href="/onchain" { button { "← Back" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Send On-chain Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -471,10 +471,10 @@ async fn execute_onchain_transaction(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Send On-chain Result", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }

+ 14 - 14
crates/cdk-ldk-node/src/web/handlers/payments.rs

@@ -371,13 +371,13 @@ pub async fn post_pay_bolt11(
                     a href="/payments" { button { "← Try Again" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Payment Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -415,13 +415,13 @@ pub async fn post_pay_bolt11(
                     a href="/payments" { button { "← Try Again" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::INTERNAL_SERVER_ERROR)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Payment Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -503,12 +503,12 @@ pub async fn post_pay_bolt11(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Payment Result", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }
 
 pub async fn post_pay_bolt12(
@@ -525,13 +525,13 @@ pub async fn post_pay_bolt12(
                     a href="/payments" { button { "← Try Again" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::BAD_REQUEST)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Payment Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -559,13 +559,13 @@ pub async fn post_pay_bolt12(
                             a href="/payments" { button { "← Try Again" } }
                         }
                     };
-                    return Ok(Response::builder()
+                    return Response::builder()
                         .status(StatusCode::BAD_REQUEST)
                         .header("content-type", "text/html")
                         .body(Body::from(
                             layout_with_status("Payment Error", content, true).into_string(),
                         ))
-                        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
                 }
             };
             let amount_msats = amount_btc * 1_000;
@@ -593,13 +593,13 @@ pub async fn post_pay_bolt12(
                     a href="/payments" { button { "← Try Again" } }
                 }
             };
-            return Ok(Response::builder()
+            return Response::builder()
                 .status(StatusCode::INTERNAL_SERVER_ERROR)
                 .header("content-type", "text/html")
                 .body(Body::from(
                     layout_with_status("Payment Error", content, true).into_string(),
                 ))
-                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?);
+                .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR);
         }
     };
 
@@ -688,10 +688,10 @@ pub async fn post_pay_bolt12(
         }
     };
 
-    Ok(Response::builder()
+    Response::builder()
         .header("content-type", "text/html")
         .body(Body::from(
             layout_with_status("Payment Result", content, true).into_string(),
         ))
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?)
+        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
 }

+ 0 - 12
crates/cdk-ldk-node/src/web/handlers/utils.rs

@@ -1,22 +1,10 @@
 use std::sync::Arc;
 
-use axum::body::Body;
-use axum::http::{Response, StatusCode};
 use ldk_node::payment::PaymentDirection;
 use serde::Deserialize;
 
 use crate::CdkLdkNode;
 
-/// Build a response, converting builder errors to INTERNAL_SERVER_ERROR
-pub fn build_response(
-    builder: axum::http::response::Builder,
-    body: Body,
-) -> Result<Response<Body>, StatusCode> {
-    builder
-        .body(body)
-        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
-}
-
 #[derive(Clone)]
 pub struct AppState {
     pub node: Arc<CdkLdkNode>,

+ 1 - 0
crates/cdk-lnbits/src/lib.rs

@@ -3,6 +3,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::cmp::max;
 use std::pin::Pin;

+ 1 - 0
crates/cdk-lnd/src/lib.rs

@@ -5,6 +5,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::cmp::max;
 use std::path::PathBuf;

+ 1 - 0
crates/cdk-mint-rpc/src/lib.rs

@@ -1,6 +1,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 pub mod proto;
 
 pub mod mint_rpc_cli;

+ 9 - 3
crates/cdk-mintd/src/lib.rs

@@ -1,4 +1,5 @@
 //! Cdk mintd lib
+#![deny(clippy::unwrap_used)]
 
 // std
 #[cfg(feature = "auth")]
@@ -322,7 +323,9 @@ async fn setup_sqlite_database(
     #[cfg(feature = "sqlcipher")]
     let db = {
         // Get password from command line arguments for sqlcipher
-        MintSqliteDatabase::new((sql_db_path, _password.unwrap())).await?
+        let password = _password
+            .ok_or_else(|| anyhow!("Password required when sqlcipher feature is enabled"))?;
+        MintSqliteDatabase::new((sql_db_path, password)).await?
     };
 
     Ok(Arc::new(db))
@@ -649,7 +652,10 @@ async fn setup_authentication(
                     #[cfg(feature = "sqlcipher")]
                     let sqlite_db = {
                         // Get password from command line arguments for sqlcipher
-                        MintSqliteAuthDatabase::new((sql_db_path, _password.unwrap())).await?
+                        let password = _password.clone().ok_or_else(|| {
+                            anyhow!("Password required when sqlcipher feature is enabled")
+                        })?;
+                        MintSqliteAuthDatabase::new((sql_db_path, password)).await?
                     };
 
                     Arc::new(sqlite_db)
@@ -1027,7 +1033,7 @@ async fn start_services_with_shutdown(
 
     let listener = tokio::net::TcpListener::bind(socket_addr).await?;
 
-    tracing::info!("listening on {}", listener.local_addr().unwrap());
+    tracing::info!("listening on {}", listener.local_addr()?);
 
     // Create a task to wait for the shutdown signal and broadcast it
     let shutdown_broadcast_task = {

+ 1 - 0
crates/cdk-mintd/src/main.rs

@@ -1,6 +1,7 @@
 //! CDK MINTD
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 use std::sync::Arc;
 

+ 1 - 0
crates/cdk-payment-processor/src/lib.rs

@@ -1,6 +1,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 pub mod error;
 /// Protocol types and functionality for the CDK payment processor

+ 3 - 4
crates/cdk-payment-processor/src/proto/server.rs

@@ -247,7 +247,8 @@ impl CdkPaymentProcessor for PaymentProcessorServer {
 
                 cdk_common::payment::OutgoingPaymentOptions::Bolt12(Box::new(
                     cdk_common::payment::Bolt12OutgoingPaymentOptions {
-                        offer: Offer::from_str(&request.request).unwrap(),
+                        offer: Offer::from_str(&request.request)
+                            .expect("Already validated offer above"),
                         max_fee_amount: None,
                         timeout_secs: None,
                         melt_options: request.options.map(Into::into),
@@ -298,9 +299,7 @@ impl CdkPaymentProcessor for PaymentProcessorServer {
                 (CurrencyUnit::Msat, payment_options)
             }
             outgoing_payment_variant::Options::Bolt12(opts) => {
-                let offer = Offer::from_str(&opts.offer)
-                    .map_err(|_| Error::Bolt12Parse)
-                    .unwrap();
+                let offer = Offer::from_str(&opts.offer).map_err(|_| Error::Bolt12Parse)?;
 
                 let payment_options = cdk_common::payment::OutgoingPaymentOptions::Bolt12(
                     Box::new(cdk_common::payment::Bolt12OutgoingPaymentOptions {

+ 2 - 0
crates/cdk-postgres/src/lib.rs

@@ -1,3 +1,5 @@
+#![deny(clippy::unwrap_used)]
+
 use std::fmt::Debug;
 use std::sync::atomic::AtomicBool;
 use std::sync::{Arc, OnceLock};

+ 1 - 0
crates/cdk-prometheus/src/lib.rs

@@ -1,4 +1,5 @@
 //! # CDK Prometheus
+#![deny(clippy::unwrap_used)]
 
 pub mod error;
 pub mod metrics;

+ 1 - 0
crates/cdk-redb/src/lib.rs

@@ -3,6 +3,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 pub mod error;
 mod migrations;

+ 4 - 5
crates/cdk-redb/src/wallet/mod.rs

@@ -250,11 +250,10 @@ impl WalletDatabase for WalletRedbDatabase {
             .iter()
             .map_err(Error::from)?
             .flatten()
-            .map(|(mint, mint_info)| {
-                (
-                    MintUrl::from_str(mint.value()).unwrap(),
-                    serde_json::from_str(mint_info.value()).ok(),
-                )
+            .filter_map(|(mint, mint_info)| {
+                MintUrl::from_str(mint.value())
+                    .ok()
+                    .map(|url| (url, serde_json::from_str(mint_info.value()).ok()))
             })
             .collect();
 

+ 1 - 0
crates/cdk-signatory/src/lib.rs

@@ -7,6 +7,7 @@
 //! module, all communication is done through the Signatory trait and the signatory manager.
 #![deny(missing_docs)]
 #![deny(warnings)]
+#![deny(clippy::unwrap_used)]
 
 #[cfg(feature = "grpc")]
 mod proto;

+ 1 - 0
crates/cdk-sqlite/src/lib.rs

@@ -2,6 +2,7 @@
 
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 mod async_sqlite;
 mod common;

+ 1 - 0
crates/cdk/src/lib.rs

@@ -2,6 +2,7 @@
 #![doc = include_str!("../README.md")]
 #![warn(missing_docs)]
 #![warn(rustdoc::bare_urls)]
+#![deny(clippy::unwrap_used)]
 
 // Disallow enabling `tor` feature on wasm32 with a clear error.
 #[cfg(all(target_arch = "wasm32", feature = "tor"))]