mod address;
mod amount;
mod atomic_swap;
mod conditions;
mod error;
mod hash;
mod keys;
mod mnemonic;
pub mod pq;
pub mod tx;
pub use address::Address;
pub use amount::{Amount, NIBBLES_PER_BYTE};
pub use atomic_swap::{
AtomicSwap, AtomicSwapParams, ChainClock, SwapLeg, SwapLocks, SwapSecret, SwapTimeouts,
};
pub use conditions::{
Condition, ConditionTemplates, EscrowRefundTemplate, HtlcTemplate, PaymentChannelTemplate,
};
pub use error::{Error, Result};
pub use keys::{PrivateKey, PublicKey, Signature};
pub use mnemonic::{mnemonic_from_private_key, private_key_from_mnemonic};
pub use pq::{PQAddress, PQKeypair, PQNetwork, PQSignature};
pub const MAINNET_CHAIN_ID: &str = "torvyon-mainnet";
pub const TESTNET_CHAIN_ID: &str = "torvyon-testnet-1";
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Network {
Mainnet,
Testnet,
}
impl Network {
pub const fn chain_id(self) -> &'static str {
match self {
Self::Mainnet => MAINNET_CHAIN_ID,
Self::Testnet => TESTNET_CHAIN_ID,
}
}
pub const fn address_prefix(self) -> &'static str {
match self {
Self::Mainnet => "bt1",
Self::Testnet => "tbt1",
}
}
pub fn from_chain_id(chain_id: &str) -> Self {
match chain_id {
TESTNET_CHAIN_ID => Self::Testnet,
_ => Self::Mainnet,
}
}
pub fn from_address(address: &str) -> Self {
if address.starts_with(Self::Testnet.address_prefix()) {
Self::Testnet
} else {
Self::Mainnet
}
}
}