Skip to main content

Network

Enum Network 

Source
pub enum Network {
    Mainnet,
    Testnet3,
    Testnet4,
    Signet,
    Regtest,
}
Expand description

A supported Bitcoin network.

Variants§

§

Mainnet

Bitcoin mainnet.

§

Testnet3

Bitcoin public testnet version 3.

§

Testnet4

Bitcoin public testnet version 4.

§

Signet

Bitcoin default signet.

§

Regtest

Local regression-test network.

Implementations§

Source§

impl Network

Source

pub const fn magic(self) -> [u8; 4]

Returns the four P2P message-start bytes in wire order.

Source

pub const fn default_p2p_port(self) -> u16

Returns the default P2P port.

Source

pub const fn bip34_activation_height(self) -> u32

Returns the network’s BIP34 coinbase-height activation height.

Per Bitcoin Core’s chainparams.cpp for fixed public networks:

  • Mainnet activates at height 227,931
  • Testnet3 activates at height 21,111
  • Testnet4 / Signet activate at height 1
  • This crate’s deterministic regtest default activates at height 500.
Source

pub const fn bip34_activation_hash(self) -> Option<Hash256>

Returns the fixed BIP34 activation block hash when Core uses one to prove that BIP34 implies BIP30 on a known chain.

Source

pub const fn is_bip34_active(self, height: u32) -> bool

Returns true when BIP34 coinbase-height encoding is enforced at height.

Source

pub const fn is_bip65_active(self, height: u32) -> bool

Returns true when BIP65 (OP_CHECKLOCKTIMEVERIFY) is enforced at height.

Per Bitcoin Core’s chainparams.cpp:

  • Mainnet activates at height 388,381
  • Testnet3 activates at height 581,885
  • Testnet4 / Signet activate at height 1
  • Regtest activates at height 1,351
Source

pub const fn is_bip66_active(self, height: u32) -> bool

Returns true when BIP66 (strict DER signatures) is enforced at height.

Source

pub const fn is_csv_active(self, height: u32) -> bool

Returns true when CSV (BIP68/112/113 relative locktime + MTP) is enforced at height.

Source

pub const fn is_segwit_active(self, height: u32) -> bool

Returns true when Segwit (BIP141/143/147) is enforced at height.

Source

pub const fn is_taproot_active(self, height: u32) -> bool

Returns true when Taproot (BIP341/342) is enforced at height.

Source

pub const fn default_rpc_port(self) -> u16

Returns the default JSON-RPC port used by Bitcoin Core.

Source

pub const fn dns_seeds(self) -> &'static [&'static str]

Returns DNS seeds from Bitcoin Core chain parameters.

Source

pub const fn max_target(self) -> Uint<256, 4>

Returns the proof-of-work limit target.

Source

pub const fn retarget_interval(self) -> u32

Returns the main retarget interval in blocks.

Source

pub const fn target_spacing_seconds(self) -> u32

Returns the proof-of-work target spacing in seconds.

Source

pub const fn target_timespan_seconds(self) -> u32

Returns the proof-of-work retarget timespan in seconds.

Source

pub const fn allow_min_difficulty_blocks(self) -> bool

Returns whether non-retarget blocks may use the test-network minimum-difficulty rule.

Source

pub const fn pow_no_retargeting(self) -> bool

Returns whether retarget heights keep the previous difficulty unchanged.

Source

pub const fn enforce_bip94(self) -> bool

Returns whether retargeting uses the first block of the period as the base difficulty.

Source

pub fn genesis_block_hash(self) -> Hash256

Returns the genesis block hash.

Trait Implementations§

Source§

impl Clone for Network

Source§

fn clone(&self) -> Network

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Network

Source§

impl Debug for Network

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Network

Source§

impl Hash for Network

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Network

Source§

fn eq(&self, other: &Network) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Network

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more