Skip to content
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
11 changes: 11 additions & 0 deletions client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ impl ExtendedNetwork {
ExtendedNetwork::Testnet4 => Network::Testnet,
}
}

pub fn from_core_arg(arg: &str) -> Result<Self, ()> {
match arg.to_lowercase().as_str() {
"main" => Ok(ExtendedNetwork::Mainnet),
"test" => Ok(ExtendedNetwork::Testnet),
"testnet4" => Ok(ExtendedNetwork::Testnet4),
"signet" => Ok(ExtendedNetwork::Signet),
"regtest" => Ok(ExtendedNetwork::Regtest),
_ => Err(()),
}
}
}

impl Args {
Expand Down
18 changes: 10 additions & 8 deletions client/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub(crate) type Responder<T> = oneshot::Sender<T>;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerInfo {
pub network: String,
pub network: ExtendedNetwork,
pub tip: ChainAnchor,
pub chain: ChainInfo,
pub ready: bool,
Expand Down Expand Up @@ -1632,16 +1632,18 @@ async fn get_server_info(
.await
.map_err(|e| anyhow!("Could not retrieve blockchain info ({})", e))?;

let start_block = if info.chain == "main" {
871_222
} else if info.chain.starts_with("test") {
50_000
} else {
0
let network = info.chain;
let network = ExtendedNetwork::from_core_arg(&network)
.map_err(|_| anyhow!("Unknown network ({})", &network))?;

let start_block = match network {
ExtendedNetwork::Mainnet => 871_222,
ExtendedNetwork::Testnet | ExtendedNetwork::Testnet4 => 50_000,
_ => 0,
};

Ok(ServerInfo {
network: info.chain,
network,
tip,
chain: ChainInfo {
blocks: info.blocks,
Expand Down
Loading