From c2c5485c67b218d092b35e238a1c54da5692fcda Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Wed, 7 Jan 2026 14:59:44 -0300 Subject: [PATCH 1/2] refactor(submit_package): use `unwrap_or_default` instead of `.unwrap()` - use `unwrap_or_default()` instead of `.unwrap()`, ideally it should return a specific error variant, it'd be a breaking change though and can be added in a follow-up. - it's only possible to use the internal `minreq::Error` to wrap the `serde_json::Error`, but not the `reqwest::Error` as it does not have public constructors. --- src/async.rs | 2 +- src/blocking.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/async.rs b/src/async.rs index 2a6cf52..9f8e854 100644 --- a/src/async.rs +++ b/src/async.rs @@ -410,7 +410,7 @@ impl AsyncClient { let response = self .post_request_bytes( "/txs/package", - serde_json::to_string(&serialized_txs).unwrap(), + serde_json::to_string(&serialized_txs).unwrap_or_default(), Some(queryparams), ) .await?; diff --git a/src/blocking.rs b/src/blocking.rs index 23425a4..0be6dbe 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -332,9 +332,8 @@ impl BlockingClient { let mut request = self.post_request( "/txs/package", serde_json::to_string(&serialized_txs) - .unwrap() - .as_bytes() - .to_vec(), + .unwrap_or_default() + .into_bytes(), )?; if let Some(maxfeerate) = maxfeerate { From ea9b5d1c0425344fa7289191dfd1f425dc11692a Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Thu, 8 Jan 2026 00:22:09 -0300 Subject: [PATCH 2/2] refactor(blocking): propagate `hex-conservative` errors instead of `.unwrap()`. --- src/blocking.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blocking.rs b/src/blocking.rs index 0be6dbe..3e68e6c 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -144,7 +144,7 @@ impl BlockingClient { } Ok(resp) => { let hex_str = resp.as_str().map_err(Error::Minreq)?; - let hex_vec = Vec::from_hex(hex_str).unwrap(); + let hex_vec = Vec::from_hex(hex_str)?; deserialize::(&hex_vec) .map_err(Error::BitcoinEncoding) .map(|r| Some(r)) @@ -162,7 +162,7 @@ impl BlockingClient { } Ok(resp) => { let hex_str = resp.as_str().map_err(Error::Minreq)?; - let hex_vec = Vec::from_hex(hex_str).unwrap(); + let hex_vec = Vec::from_hex(hex_str)?; deserialize::(&hex_vec).map_err(Error::BitcoinEncoding) } Err(e) => Err(e),