Enum lnpbp_chain::Chain
source · [−]#[non_exhaustive]
#[repr(u32)]
pub enum Chain {
Mainnet,
Testnet3,
Regtest(BlockHash),
Signet,
SignetCustom(BlockHash),
LiquidV1,
Other(Box<ChainParams>),
}
Expand description
A set of recommended standard networks. Differs from bitcoin::Network in ability to support non-standard and non-predefined networks
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Mainnet
Bitcoin mainnet
Testnet3
Bitcoin testnet version 3
Regtest(BlockHash)
Bitcoin regtest network, with provided genesis hash to distinguish different private networks
Signet
Default bitcoin signet network
SignetCustom(BlockHash)
Some private bitcoin signet network, with provided genesis hash to distinguish private networks from each other
LiquidV1
Liquidv1 sidechain & network by Blockstream
Other(Box<ChainParams>)
All other networks/chains, providing full information on chain parameters
Implementations
sourceimpl Chain
impl Chain
sourcepub fn all_standard() -> &'static [Chain]
pub fn all_standard() -> &'static [Chain]
Enumerates all known standard bitcoin (BP) chains
sourcepub fn chain_params(&self) -> ChainParams
pub fn chain_params(&self) -> ChainParams
Returns chain parameters ChainParams for a given chain id
sourcepub fn as_genesis_hash(&self) -> &BlockHash
pub fn as_genesis_hash(&self) -> &BlockHash
Returns hash of genesis block
sourcepub fn from_genesis_hash(hash: &BlockHash) -> Option<Self>
pub fn from_genesis_hash(hash: &BlockHash) -> Option<Self>
Gueses chain from the given genesis block hash, returning Option::None if the hash is unknown. This implies that for custom signet and some regtest networks with modified genesis the function will fail.
sourcepub fn native_asset(&self) -> AssetId
pub fn native_asset(&self) -> AssetId
Returns native chain asset
Trait Implementations
sourceimpl From<&ChainParams> for Chain
impl From<&ChainParams> for Chain
sourcefn from(params: &ChainParams) -> Self
fn from(params: &ChainParams) -> Self
Converts to this type from the input type.
sourceimpl From<ChainParams> for Chain
impl From<ChainParams> for Chain
sourcefn from(params: ChainParams) -> Self
fn from(params: ChainParams) -> Self
Converts to this type from the input type.
sourceimpl Ord for Chain
impl Ord for Chain
sourceimpl PartialOrd<Chain> for Chain
impl PartialOrd<Chain> for Chain
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl StrictDecode for Chain
impl StrictDecode for Chain
sourcefn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
Decode with the given std::io::Read
instance; must either
construct an instance or return implementation-specific error type. Read more
sourcefn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
Tries to deserialize byte array into the current type using
StrictDecode::strict_decode
. If there are some data remains in the
buffer once deserialization is completed, fails with
Error::DataNotEntirelyConsumed
. Use io::Cursor
over the buffer and
StrictDecode::strict_decode
to avoid such failures. Read more
sourcefn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
Reads data from file at path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction. Read more
sourceimpl StrictEncode for Chain
impl StrictEncode for Chain
sourcefn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
Encode with the given std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type. Read more
sourcefn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
Serializes data as a byte array using StrictEncode::strict_encode
function Read more
impl Eq for Chain
Auto Trait Implementations
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnwindSafe for Chain
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more