add Network::to_core_arg() method

This commit is contained in:
connormullett 2022-11-17 17:25:00 -05:00
parent 1696038313
commit 519db4d951
1 changed files with 18 additions and 0 deletions

View File

@ -101,6 +101,24 @@ impl Network {
/// assert_eq!(network.magic(), Magic::from_bytes([0xF9, 0xBE, 0xB4, 0xD9]));
/// ```
pub fn magic(self) -> Magic { Magic::from(self) }
/// Converts a `Network` to its equivalent `bitcoind -chain` argument name.
///
/// ```bash,no_run
/// $ bitcoin-23.0/bin/bitcoind --help | grep -C 3 '\-chain=<chain>'
/// Chain selection options:
///
/// -chain=<chain>
/// Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest
/// ```
pub fn to_core_arg(self) -> &'static str {
match self {
Network::Bitcoin => "main",
Network::Testnet => "test",
Network::Signet => "signet",
Network::Regtest => "regtest",
}
}
}
/// An error in parsing network string.