use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Network {
Mainnet,
Testnet,
}
impl std::fmt::Display for Network {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Network::Mainnet => write!(f, "mainnet"),
Network::Testnet => write!(f, "testnet"),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct HexOptions {
pub prefix: bool,
pub uppercase: bool,
}
impl HexOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_prefix(mut self, prefix: bool) -> Self {
self.prefix = prefix;
self
}
pub fn with_uppercase(mut self, uppercase: bool) -> Self {
self.uppercase = uppercase;
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KeyExport {
pub address: String,
pub wif: String,
pub hex: String,
pub public_key: String,
pub network: String,
pub compressed: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CsvColumn {
Address,
Wif,
Hex,
PublicKey,
Network,
}
impl CsvColumn {
pub fn header(&self) -> &'static str {
match self {
CsvColumn::Address => "address",
CsvColumn::Wif => "wif",
CsvColumn::Hex => "hex",
CsvColumn::PublicKey => "public_key",
CsvColumn::Network => "network",
}
}
}
#[derive(Debug, Clone)]
pub struct CsvOptions {
pub columns: Vec<CsvColumn>,
pub header: bool,
pub network: Network,
}
impl Default for CsvOptions {
fn default() -> Self {
Self {
columns: vec![
CsvColumn::Address,
CsvColumn::Wif,
CsvColumn::Hex,
],
header: true,
network: Network::Mainnet,
}
}
}
impl CsvOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_columns(mut self, columns: Vec<CsvColumn>) -> Self {
self.columns = columns;
self
}
pub fn with_header(mut self, header: bool) -> Self {
self.header = header;
self
}
pub fn with_network(mut self, network: Network) -> Self {
self.network = network;
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaperWallet {
pub address: String,
pub wif: String,
pub network: String,
pub address_type: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AddressType {
P2PKH,
P2WPKH,
P2TR,
}
impl std::fmt::Display for AddressType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AddressType::P2PKH => write!(f, "p2pkh"),
AddressType::P2WPKH => write!(f, "p2wpkh"),
AddressType::P2TR => write!(f, "p2tr"),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct Bip21Options {
pub amount: Option<f64>,
pub label: Option<String>,
pub message: Option<String>,
}
impl Bip21Options {
pub fn new() -> Self {
Self::default()
}
pub fn with_amount(mut self, amount: f64) -> Self {
self.amount = Some(amount);
self
}
pub fn with_label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn with_message(mut self, message: impl Into<String>) -> Self {
self.message = Some(message.into());
self
}
}