From ad864bf8af7d2f5e6ab48044b30d3e8b6fa74c72 Mon Sep 17 00:00:00 2001 From: Sosthene00 <674694@protonmail.ch> Date: Thu, 11 Aug 2022 15:42:36 +0200 Subject: [PATCH] Add signet-magic to config --- internal/config_specification.toml | 5 +++++ src/config.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/config_specification.toml b/internal/config_specification.toml index 8ffde6b..89d1320 100644 --- a/internal/config_specification.toml +++ b/internal/config_specification.toml @@ -131,3 +131,8 @@ default = "concat!(\"Welcome to electrs \", env!(\"CARGO_PKG_VERSION\"), \" (Ele name = "log_filters" type = "String" doc = "Logging filters, overriding `RUST_LOG` environment variable (see https://docs.rs/env_logger/ for details)" + +[[param]] +name = "signet_magic" +type = "u32" +doc = "network magic for custom signet network (signet only)" diff --git a/src/config.rs b/src/config.rs index 5eda9c1..54ade2b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -144,6 +144,7 @@ pub struct Config { pub sync_once: bool, pub disable_electrum_rpc: bool, pub server_banner: String, + pub signet_magic: u32, pub args: Vec, } @@ -231,6 +232,15 @@ impl Config { Network::Signet => 34224, }; + let magic = match (config.network, config.signet_magic) { + (Network::Signet, Some(magic)) => magic, + (network, None) => network.magic(), + (_, Some(_)) => { + eprintln!("Error: signet magic only available on signet"); + std::process::exit(1); + }, + }; + let daemon_rpc_addr: SocketAddr = config.daemon_rpc_addr.map_or( (DEFAULT_SERVER_ADDRESS, default_daemon_rpc_port).into(), ResolvAddr::resolve_or_exit, @@ -323,6 +333,7 @@ impl Config { sync_once: config.sync_once, disable_electrum_rpc: config.disable_electrum_rpc, server_banner: config.server_banner, + signet_magic: magic, args: args.map(|a| a.into_string().unwrap()).collect(), }; eprintln!(