#[derive(PartialEq, Eq, Debug, Clone, Copy, PartialOrd, Ord, Hash)]
pub enum Network {
Bitcoin,
Testnet,
Signet,
Regtest,
Litecoin,
LitecoinTestnet,
Vertcoin,
VertcoinTestnet,
}
pub fn hrp(network: &Network) -> String {
match *network {
Network::Bitcoin => "bc".to_string(),
Network::Testnet => "tb".to_string(),
Network::Signet => "sb".to_string(),
Network::Litecoin => "ltc".to_string(),
Network::LitecoinTestnet => "tltc".to_string(),
Network::Vertcoin => "vtc".to_string(),
Network::VertcoinTestnet => "tvtc".to_string(),
Network::Regtest => "bcrt".to_string(),
}
}
pub fn classify(hrp: &str) -> Option<Network> {
match hrp {
"bc" => Some(Network::Bitcoin),
"tb" => Some(Network::Testnet),
"sb" => Some(Network::Signet),
"ltc" => Some(Network::Litecoin),
"tltc" => Some(Network::LitecoinTestnet),
"vtc" => Some(Network::Vertcoin),
"tvtc" => Some(Network::VertcoinTestnet),
"bcrt" => Some(Network::Regtest),
_ => None
}
}