diff --git a/mutiny-core/src/lsp/voltage.rs b/mutiny-core/src/lsp/voltage.rs index 5d9ce7143..a5b3b3cab 100644 --- a/mutiny-core/src/lsp/voltage.rs +++ b/mutiny-core/src/lsp/voltage.rs @@ -152,7 +152,7 @@ impl LspClient { url: &str, logger: &MutinyLogger, ) -> Result<(PublicKey, String), MutinyError> { - let builder = http_client.get(format!("{}{}", url, GET_INFO_PATH)); + let builder = http_client.get(format!("{}{}", url.trim(), GET_INFO_PATH)); let request = add_x_auth_token_if_needed(url, builder)?; let response: reqwest::Response = utils::fetch_with_timeout(http_client, request) @@ -296,7 +296,7 @@ impl Lsp for LspClient { let builder = self .http_client - .post(format!("{}{}", &self.url, PROPOSAL_PATH)) + .post(format!("{}{}", &self.url.trim(), PROPOSAL_PATH)) .json(&payload); let request = add_x_auth_token_if_needed(&self.url, builder)?; @@ -353,7 +353,7 @@ impl Lsp for LspClient { async fn get_lsp_fee_msat(&self, fee_request: FeeRequest) -> Result { let builder = self .http_client - .post(format!("{}{}", &self.url, FEE_PATH)) + .post(format!("{}{}", &self.url.trim(), FEE_PATH)) .json(&fee_request); let request = add_x_auth_token_if_needed(&self.url, builder)?; diff --git a/mutiny-core/src/nodemanager.rs b/mutiny-core/src/nodemanager.rs index f7eb9b0c1..b66d5c434 100644 --- a/mutiny-core/src/nodemanager.rs +++ b/mutiny-core/src/nodemanager.rs @@ -59,6 +59,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; #[cfg(not(target_arch = "wasm32"))] use std::time::Instant; use std::{collections::HashMap, ops::Deref, sync::Arc}; +use url::Url; #[cfg(target_arch = "wasm32")] use web_time::Instant; @@ -2036,8 +2037,14 @@ pub fn create_lsp_config( ) -> Result, MutinyError> { match (lsp_url.clone(), lsp_connection_string.clone()) { (Some(lsp_url), None) => { - if !lsp_url.is_empty() { - Ok(Some(LspConfig::new_voltage_flow(lsp_url))) + let trimmed = lsp_url.trim().to_string(); + if !trimmed.is_empty() { + // make sure url is valid + if Url::parse(&trimmed).is_err() { + return Err(MutinyError::InvalidArgumentsError); + } + + Ok(Some(LspConfig::new_voltage_flow(trimmed))) } else { Ok(None) }