Skip to content

Commit

Permalink
Merge pull request #1234 from bonomat/fix/app-config
Browse files Browse the repository at this point in the history
fix: use string for url instead of URL
  • Loading branch information
holzeis authored Sep 6, 2023
2 parents 5470da5 + 2d201d7 commit b41549c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion mobile/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ tokio = { version = "1.25.0", features = ["macros", "rt", "rt-multi-thread", "sy
tracing = "0.1.37"
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "env-filter", "time", "json"] }
trade = { path = "../../crates/trade" }
url = "2.3.1"
uuid = { version = "1.3.0", features = ["v4", "fast-rng", "macro-diagnostics"] }
2 changes: 1 addition & 1 deletion mobile/native/src/channel_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl ChannelFeePaymentSubscriber {

async fn fetch_funding_transaction(txid: Txid) -> Result<EsploraTransaction> {
reqwest_client()
.get(format!("{}tx/{txid}", config::get_esplora_endpoint()))
.get(format!("{}/tx/{txid}", config::get_esplora_endpoint()))
.send()
.await?
.json()
Expand Down
4 changes: 1 addition & 3 deletions mobile/native/src/config/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use bdk::bitcoin::Network;
use bdk::bitcoin::XOnlyPublicKey;
use flutter_rust_bridge::frb;
use std::str::FromStr;
use url::Url;

#[frb]
#[derive(Debug, Clone)]
Expand All @@ -24,8 +23,7 @@ impl From<Config> for ConfigInternal {
tracing::debug!(?config, "Parsing config from flutter");
Self {
coordinator_pubkey: config.coordinator_pubkey.parse().expect("PK to be valid"),
esplora_endpoint: Url::parse(config.esplora_endpoint.as_str())
.expect("esplora endpoint to be valid"),
esplora_endpoint: config.esplora_endpoint,
http_endpoint: format!("{}:{}", config.host, config.http_port)
.parse()
.expect("host and http_port to be valid"),
Expand Down
5 changes: 2 additions & 3 deletions mobile/native/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ use ln_dlc_node::node::OracleInfo;
use state::Storage;
use std::net::SocketAddr;
use std::time::Duration;
use url::Url;

static CONFIG: Storage<ConfigInternal> = Storage::new();

#[derive(Clone)]
pub struct ConfigInternal {
coordinator_pubkey: PublicKey,
esplora_endpoint: Url,
esplora_endpoint: String,
http_endpoint: SocketAddr,
p2p_endpoint: SocketAddr,
network: bitcoin::Network,
Expand Down Expand Up @@ -47,7 +46,7 @@ pub fn get_coordinator_info() -> NodeInfo {
}
}

pub fn get_esplora_endpoint() -> Url {
pub fn get_esplora_endpoint() -> String {
CONFIG.get().esplora_endpoint.clone()
}

Expand Down
2 changes: 1 addition & 1 deletion mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn run(data_dir: String, seed_dir: String, runtime: &Runtime) -> Result<()>
address,
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), address.port()),
util::into_net_addresses(address),
config::get_esplora_endpoint().to_string(),
config::get_esplora_endpoint(),
seed,
ephemeral_randomness,
LnDlcNodeSettings::default(),
Expand Down

0 comments on commit b41549c

Please sign in to comment.