hal_simplicity/
lib.rs

1pub extern crate simplicity;
2
3pub mod address;
4pub mod block;
5pub mod hal_simplicity;
6pub mod tx;
7
8pub mod confidential;
9
10pub use elements::bitcoin;
11pub use hal::HexBytes;
12
13use elements::AddressParams;
14use serde::{Deserialize, Serialize};
15
16/// Known Elements networks.
17#[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Serialize)]
18#[serde(rename_all = "lowercase")]
19pub enum Network {
20	ElementsRegtest,
21	Liquid,
22}
23
24impl Network {
25	pub fn from_params(params: &'static AddressParams) -> Option<Network> {
26		if *params == AddressParams::ELEMENTS {
27			Some(Network::ElementsRegtest)
28		} else if *params == AddressParams::LIQUID {
29			Some(Network::Liquid)
30		} else {
31			None
32		}
33	}
34
35	pub fn address_params(self) -> &'static AddressParams {
36		match self {
37			Network::ElementsRegtest => &AddressParams::ELEMENTS,
38			Network::Liquid => &AddressParams::LIQUID,
39		}
40	}
41}
42
43/// Get JSON-able objects that describe the type.
44pub trait GetInfo<T: ::serde::Serialize> {
45	/// Get a description of this object given the network of interest.
46	fn get_info(&self, network: Network) -> T;
47}