Skip to content

Commit

Permalink
Merge pull request #25 from CounterpartyXCP/network
Browse files Browse the repository at this point in the history
Accept `main` and `test` for Network, like `bitcoind` and `counterparty-server`
  • Loading branch information
adamkrellenstein authored Mar 26, 2024
2 parents 24ed0e6 + 8d03726 commit 88cab79
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 88cab79

Please sign in to comment.