1#![deny(clippy::pedantic)]
2#![allow(clippy::cast_possible_wrap)]
3#![allow(clippy::missing_errors_doc)]
4#![allow(clippy::missing_panics_doc)]
5#![allow(clippy::must_use_candidate)]
6#![allow(clippy::return_self_not_must_use)]
7#![allow(clippy::large_futures)]
8
9use bitcoin::Network;
11use fedimint_core::envs::BitcoinRpcConfig;
12use fedimint_core::util::SafeUrl;
13pub use fedimintd::*;
14
15mod fedimintd;
16
17pub mod envs;
18use crate::envs::FM_PORT_ESPLORA_ENV;
19
20pub fn default_esplora_server(network: Network) -> BitcoinRpcConfig {
21 let url = match network {
22 Network::Bitcoin => SafeUrl::parse("https://blockstream.info/api/")
23 .expect("Failed to parse default esplora server"),
24 Network::Testnet => SafeUrl::parse("https://blockstream.info/testnet/api/")
25 .expect("Failed to parse default esplora server"),
26 Network::Regtest => SafeUrl::parse(&format!(
27 "http://127.0.0.1:{}/",
28 std::env::var(FM_PORT_ESPLORA_ENV).unwrap_or(String::from("50002"))
29 ))
30 .expect("Failed to parse default esplora server"),
31 Network::Signet => SafeUrl::parse("https://blockstream.info/signet/api/")
32 .expect("Failed to parse default esplora server"),
33 _ => panic!("Failed to parse default esplora server"),
34 };
35 BitcoinRpcConfig {
36 kind: "esplora".to_string(),
37 url,
38 }
39}