Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use string for url instead of URL #1234

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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