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§
source§impl 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§
source§impl From<&ChainParams> for Chain
impl From<&ChainParams> for Chain
source§fn from(params: &ChainParams) -> Self
fn from(params: &ChainParams) -> Self
source§impl From<ChainParams> for Chain
impl From<ChainParams> for Chain
source§fn from(params: ChainParams) -> Self
fn from(params: ChainParams) -> Self
source§impl Ord for Chain
impl Ord for Chain
source§impl PartialEq<Chain> for Chain
impl PartialEq<Chain> for Chain
source§impl PartialOrd<Chain> for Chain
impl PartialOrd<Chain> for Chain
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StrictDecode for Chain
impl StrictDecode for Chain
source§fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
std::io::Read
instance; must either
construct an instance or return implementation-specific error type.source§fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
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.source§fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction.source§impl StrictEncode for Chain
impl StrictEncode for Chain
source§fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.source§fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
StrictEncode::strict_encode
function