pub enum Network {
Main,
Test,
Regtest,
}Expand description
Represents a Zcash network environment (mainnet, testnet, or regtest).
The Network enum identifies which Zcash network a wallet, address,
or transaction belongs to. Each network has different consensus rules,
address encodings, and initial blockchain parameters.
§Zcash Concept Relation
Zcash, like Bitcoin, operates on multiple networks:
- Mainnet: The primary Zcash network where real ZEC with monetary value is transferred
- Testnet: A testing network that simulates mainnet but uses worthless test coins
- Regtest: A private “regression test” network for local development and testing
These networks are isolated from each other, with different genesis blocks, address formats, and consensus parameters.
§Data Preservation
The Network value is critical during wallet migration to ensure addresses and
transactions are reconstructed for the correct network. Address formats differ
between networks, and migrating a wallet to an incorrect network would render
it unusable.
§Examples
In the ZeWIF format, the Network value is stored at the wallet level:
// Wallet on the main Zcash network
let network = Network::Main;
// Wallets on mainnet and testnet have incompatible address formats
match network {
Network::Main => println!("This wallet stores real ZEC"),
Network::Test => println!("This wallet stores test coins only"),
Network::Regtest => println!("This wallet is for local testing"),
}Variants§
Trait Implementations§
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
Source§impl<T> CBORDecodable for T
impl<T> CBORDecodable for T
Source§impl<T> CBOREncodable for T
impl<T> CBOREncodable for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnvelopeEncodable for T
impl<T> EnvelopeEncodable for T
Source§fn into_envelope(self) -> Envelope
fn into_envelope(self) -> Envelope
Converts the value into an envelope by using its Into<Envelope> implementation.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more