diff --git a/src/cli/args.rs b/src/cli/args.rs index 5795cab..f40e60d 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -136,17 +136,18 @@ impl Args { }; if sync { + let network = self.general.network.to_string(); let indexer = match (&self.resolver.esplora, &self.resolver.electrum, &self.resolver.mempool) { - (None, Some(url), None) => { - AnyIndexer::Electrum(Box::new(electrum::Client::new(url)?)) - } - (Some(url), None, None) => { - AnyIndexer::Esplora(Box::new(IndexerClient::new_esplora(url)?)) - } - (None, None, Some(url)) => { - AnyIndexer::Mempool(Box::new(IndexerClient::new_mempool(url)?)) - } + (None, Some(url), None) => AnyIndexer::Electrum(Box::new( + electrum::Client::new(&url.replace("{network}", &network))?, + )), + (Some(url), None, None) => AnyIndexer::Esplora(Box::new( + IndexerClient::new_esplora(&url.replace("{network}", &network))?, + )), + (None, None, Some(url)) => AnyIndexer::Mempool(Box::new( + IndexerClient::new_mempool(&url.replace("{network}", &network))?, + )), _ => { eprintln!( " - error: no blockchain indexer specified; use either --esplora \ diff --git a/src/cli/opts.rs b/src/cli/opts.rs index 7afa7b1..3eb14ce 100644 --- a/src/cli/opts.rs +++ b/src/cli/opts.rs @@ -43,8 +43,8 @@ pub const DATA_DIR: &str = "~/Documents"; pub const DATA_DIR: &str = "."; pub const DEFAULT_ELECTRUM: &str = "example.com:50001"; -pub const DEFAULT_ESPLORA: &str = "https://blockstream.info/testnet/api"; -pub const DEFAULT_MEMPOOL: &str = "https://mempool.space/testnet/api"; +pub const DEFAULT_ESPLORA: &str = "https://blockstream.info/{network}/api"; +pub const DEFAULT_MEMPOOL: &str = "https://mempool.space/{network}/api"; #[derive(Args, Clone, PartialEq, Eq, Debug)] #[group(args = ["electrum", "esplora", "mempool"])]