From 8d03726ce8afada04bd4668649dab5fdc97203a4 Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Tue, 26 Mar 2024 15:24:02 +0100 Subject: [PATCH] Accept 'main' and 'test' for Network, like bitcoind and counterparty-core --- config_spec.toml | 2 +- src/config.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config_spec.toml b/config_spec.toml index 70f9ca0..8957dfb 100644 --- a/config_spec.toml +++ b/config_spec.toml @@ -37,7 +37,7 @@ doc = "JSONRPC authentication cookie ('USER:PASSWORD', default: read from ~/.bit name = "network" type = "crate::config::BitcoinNetwork" convert_into = "::bitcoin::network::constants::Network" -doc = "Select Bitcoin network type ('mainnet', 'testnet' or 'regtest')" +doc = "Select Bitcoin network type ('mainnet', 'main', 'testnet', 'test', or 'regtest')" default = "Default::default()" [[param]] diff --git a/src/config.rs b/src/config.rs index 6d7f71b..10bb6bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -71,7 +71,11 @@ impl FromStr for BitcoinNetwork { type Err = ::Err; fn from_str(string: &str) -> std::result::Result { - Network::from_str(string).map(BitcoinNetwork) + match string { + "main" => Network::from_str("bitcoin").map(BitcoinNetwork), + "test" => Network::from_str("testnet").map(BitcoinNetwork), + _ => Network::from_str(string).map(BitcoinNetwork), + } } }