refactor: centralize constants, eliminate unwraps, remove dead code, resolve TODOs

- R13+R16: Replace .expect() with .context()? in main.rs and identity.rs
- R17+R18+R19: Fix unwrap() calls in helpers and js-engine
- R20+R21: Remove #[allow(dead_code)] annotations and delete truly dead code
- R22-R26: Create constants.rs module, replace 21 hardcoded values across 12 files
- R28+R29: LND/DWN timeouts already present — verified
- R30-R33: Remove TODO comments, implement marketplace payment check

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-21 01:54:35 +00:00
co-authored by Claude Opus 4.6
parent 5c3a3ffa8e
commit f3976ba03a
22 changed files with 113 additions and 104 deletions
+3 -3
View File
@@ -1506,7 +1506,7 @@ async fn handle_tx_relay_broadcast(
});
match client
.post("http://127.0.0.1:8332/")
.post(crate::constants::BITCOIN_RPC_URL)
.basic_auth(&rpc_user, Some(&rpc_pass))
.json(&preflight_body)
.send()
@@ -1559,7 +1559,7 @@ async fn handle_tx_relay_broadcast(
});
let txid = match client
.post("http://127.0.0.1:8332/")
.post(crate::constants::BITCOIN_RPC_URL)
.basic_auth(&rpc_user, Some(&rpc_pass))
.json(&body)
.send()
@@ -1783,7 +1783,7 @@ async fn check_tx_confirmations(client: &reqwest::Client, txid: &str) -> anyhow:
});
let (rpc_user, rpc_pass) = crate::bitcoin_rpc::bitcoin_rpc_credentials().await;
let resp = client
.post("http://127.0.0.1:8332/")
.post(crate::constants::BITCOIN_RPC_URL)
.basic_auth(&rpc_user, Some(&rpc_pass))
.json(&body)
.send()
+3 -17
View File
@@ -4,31 +4,18 @@
//! Supports Meshcore firmware on Heltec V3, T-Beam, RAK WisBlock, Station G2,
//! and other ESP32/nRF52-based LoRa boards via USB serial (Companion USB mode).
#[allow(dead_code)]
pub mod alerts;
#[allow(dead_code)]
pub mod bitcoin_relay;
#[allow(dead_code)]
pub mod crypto;
#[allow(dead_code)]
pub mod listener;
#[allow(dead_code)]
pub mod protocol;
#[allow(dead_code)]
pub mod serial;
#[allow(dead_code)]
pub mod types;
#[allow(dead_code)]
pub mod message_types;
#[allow(dead_code)]
pub mod outbox;
#[allow(dead_code)]
pub mod ratchet;
#[allow(dead_code)]
pub mod session;
#[allow(dead_code)]
pub mod steganography;
#[allow(dead_code)]
pub mod x3dh;
pub use types::*;
@@ -154,7 +141,6 @@ pub struct MeshService {
pub dead_man_switch: Arc<DeadManSwitch>,
}
#[allow(dead_code)]
impl MeshService {
/// Create a new MeshService. Does not start the listener yet.
pub async fn new(
@@ -623,7 +609,7 @@ async fn bitcoin_rpc_getblockcount(client: &reqwest::Client) -> Result<u64> {
let resp: BitcoinRpcResponse<u64> = tokio::time::timeout(
Duration::from_secs(10),
client
.post("http://127.0.0.1:8332/")
.post(crate::constants::BITCOIN_RPC_URL)
.basic_auth(&rpc_user, Some(&rpc_pass))
.json(&body)
.send()
@@ -652,7 +638,7 @@ async fn bitcoin_rpc_getblockheader_by_height(
let resp: BitcoinRpcResponse<String> = tokio::time::timeout(
Duration::from_secs(10),
client
.post("http://127.0.0.1:8332/")
.post(crate::constants::BITCOIN_RPC_URL)
.basic_auth(&rpc_user, Some(&rpc_pass))
.json(&body)
.send()
@@ -672,7 +658,7 @@ async fn bitcoin_rpc_getblockheader_by_height(
let resp: BitcoinRpcResponse<serde_json::Value> = tokio::time::timeout(
Duration::from_secs(10),
client
.post("http://127.0.0.1:8332/")
.post(crate::constants::BITCOIN_RPC_URL)
.basic_auth(&rpc_user, Some(&rpc_pass))
.json(&body)
.send()