#[non_exhaustive]pub enum Network {
Bitcoin,
Testnet,
Testnet4,
Signet,
Regtest,
}
Expand description
The cryptocurrency network to act on.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Bitcoin
Mainnet Bitcoin.
Testnet
Bitcoin’s testnet network. (In future versions this will be combined into a single variant containing the version)
Testnet4
Bitcoin’s testnet4 network. (In future versions this will be combined into a single variant containing the version)
Signet
Bitcoin’s signet network.
Regtest
Bitcoin’s regtest network.
Implementations§
Source§impl Network
impl Network
Sourcepub fn from_magic(magic: Magic) -> Option<Network>
pub fn from_magic(magic: Magic) -> Option<Network>
Creates a Network
from the magic bytes.
§Examples
use bitcoin::p2p::Magic;
use bitcoin::Network;
assert_eq!(Ok(Network::Bitcoin), Network::try_from(Magic::from_bytes([0xF9, 0xBE, 0xB4, 0xD9])));
assert_eq!(None, Network::from_magic(Magic::from_bytes([0xFF, 0xFF, 0xFF, 0xFF])));
Sourcepub fn magic(self) -> Magic
pub fn magic(self) -> Magic
Return the network magic bytes, which should be encoded little-endian at the start of every message
§Examples
use bitcoin::p2p::Magic;
use bitcoin::Network;
let network = Network::Bitcoin;
assert_eq!(network.magic(), Magic::from_bytes([0xF9, 0xBE, 0xB4, 0xD9]));
Sourcepub fn to_core_arg(self) -> &'static str
pub fn to_core_arg(self) -> &'static str
Converts a Network
to its equivalent bitcoind -chain
argument name.
$ 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
Sourcepub fn from_core_arg(core_arg: &str) -> Result<Self, ParseNetworkError>
pub fn from_core_arg(core_arg: &str) -> Result<Self, ParseNetworkError>
Converts a bitcoind -chain
argument name to its equivalent Network
.
$ 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
Sourcepub fn chain_hash(self) -> ChainHash
pub fn chain_hash(self) -> ChainHash
Return the network’s chain hash (genesis block hash).
§Examples
use bitcoin::Network;
use bitcoin::blockdata::constants::ChainHash;
let network = Network::Bitcoin;
assert_eq!(network.chain_hash(), ChainHash::BITCOIN);
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Network
impl<'de> Deserialize<'de> for Network
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Network> for NetworkKind
impl From<Network> for NetworkKind
Source§impl Ord for Network
impl Ord for Network
Source§impl PartialOrd for Network
impl PartialOrd for Network
impl Copy for Network
impl Eq for Network
impl StructuralPartialEq for Network
Auto Trait Implementations§
impl Freeze for Network
impl RefUnwindSafe for Network
impl Send for Network
impl Sync for Network
impl Unpin for Network
impl UnwindSafe for Network
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)