Skip to content

Commit

Permalink
Accept 'main' and 'test' for Network, like bitcoind and counterparty-…
Browse files Browse the repository at this point in the history
…core
  • Loading branch information
Ouziel committed Mar 26, 2024
1 parent 3e7d345 commit 8d03726
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config_spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ impl FromStr for BitcoinNetwork {
type Err = <Network as FromStr>::Err;

fn from_str(string: &str) -> std::result::Result<Self, Self::Err> {
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),
}
}
}

Expand Down

0 comments on commit 8d03726

Please sign in to comment.