Merge rust-bitcoin/rust-bitcoin#1397: Add Network::to_core_arg() method
519db4d951
add Network::to_core_arg() method (connormullett) Pull request description: closes: #1207 Adds converting `Network` to its `bitcoind` equivalent. The arguments for -chain can be found in the documentation and is one of the following: main, test, signet, regtest ACKs for top commit: apoelstra: ACK519db4d951
Kixunil: ACK519db4d951
Tree-SHA512: 5fd805d654f7c30f87ff877fe90e19490d0deb73b46ce87cc6b43d30595eb9d2de3f646f58a5d72180c3e8cc6a9b614bfe6753ecd6c21b8d193a8d862e3f887f
This commit is contained in:
commit
ac583202cf
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue