diff --git a/src/config.rs b/src/config.rs index decbbaf..4dc8cde 100644 --- a/src/config.rs +++ b/src/config.rs @@ -240,6 +240,22 @@ pub fn wallet_owner_secret_path(chain_type: &ChainTypes) -> PathBuf { path } +pub fn grin_node_url(chain_type: &ChainTypes) -> SocketAddr { + if *chain_type == ChainTypes::Testnet { + "127.0.0.1:13413".parse().unwrap() + } else { + "127.0.0.1:3413".parse().unwrap() + } +} + +pub fn wallet_owner_url(chain_type: &ChainTypes) -> SocketAddr { + if *chain_type == ChainTypes::Testnet { + "127.0.0.1:13420".parse().unwrap() + } else { + "127.0.0.1:3420".parse().unwrap() + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/main.rs b/src/main.rs index 7425812..f68e400 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,14 +70,20 @@ fn real_main() -> Result<(), Box> { key: secp::random_secret(), interval_s: round_time.unwrap_or(DEFAULT_INTERVAL), addr: bind_addr.unwrap_or("0.0.0.0:3000").parse()?, - grin_node_url: grin_node_url.unwrap_or("127.0.0.1:3413").parse()?, + grin_node_url: match grin_node_url { + Some(u) => u.parse()?, + None => config::grin_node_url(&chain_type), + }, grin_node_secret_path: match grin_node_secret_path { Some(p) => Some(p.to_owned()), None => config::node_secret_path(&chain_type) .to_str() .map(|p| p.to_owned()), }, - wallet_owner_url: wallet_owner_url.unwrap_or("127.0.0.1:3420").parse()?, + wallet_owner_url: match wallet_owner_url { + Some(u) => u.parse()?, + None => config::wallet_owner_url(&chain_type), + }, wallet_owner_secret_path: match wallet_owner_secret_path { Some(p) => Some(p.to_owned()), None => config::wallet_owner_secret_path(&chain_type)