rustywallet_export/
types.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "lowercase")]
8pub enum Network {
9 Mainnet,
11 Testnet,
13}
14
15impl std::fmt::Display for Network {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 match self {
18 Network::Mainnet => write!(f, "mainnet"),
19 Network::Testnet => write!(f, "testnet"),
20 }
21 }
22}
23
24#[derive(Debug, Clone, Default)]
26pub struct HexOptions {
27 pub prefix: bool,
29 pub uppercase: bool,
31}
32
33impl HexOptions {
34 pub fn new() -> Self {
36 Self::default()
37 }
38
39 pub fn with_prefix(mut self, prefix: bool) -> Self {
41 self.prefix = prefix;
42 self
43 }
44
45 pub fn with_uppercase(mut self, uppercase: bool) -> Self {
47 self.uppercase = uppercase;
48 self
49 }
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct KeyExport {
55 pub address: String,
57 pub wif: String,
59 pub hex: String,
61 pub public_key: String,
63 pub network: String,
65 pub compressed: bool,
67}
68
69#[derive(Debug, Clone, Copy, PartialEq, Eq)]
71pub enum CsvColumn {
72 Address,
74 Wif,
76 Hex,
78 PublicKey,
80 Network,
82}
83
84impl CsvColumn {
85 pub fn header(&self) -> &'static str {
87 match self {
88 CsvColumn::Address => "address",
89 CsvColumn::Wif => "wif",
90 CsvColumn::Hex => "hex",
91 CsvColumn::PublicKey => "public_key",
92 CsvColumn::Network => "network",
93 }
94 }
95}
96
97#[derive(Debug, Clone)]
99pub struct CsvOptions {
100 pub columns: Vec<CsvColumn>,
102 pub header: bool,
104 pub network: Network,
106}
107
108impl Default for CsvOptions {
109 fn default() -> Self {
110 Self {
111 columns: vec![
112 CsvColumn::Address,
113 CsvColumn::Wif,
114 CsvColumn::Hex,
115 ],
116 header: true,
117 network: Network::Mainnet,
118 }
119 }
120}
121
122impl CsvOptions {
123 pub fn new() -> Self {
125 Self::default()
126 }
127
128 pub fn with_columns(mut self, columns: Vec<CsvColumn>) -> Self {
130 self.columns = columns;
131 self
132 }
133
134 pub fn with_header(mut self, header: bool) -> Self {
136 self.header = header;
137 self
138 }
139
140 pub fn with_network(mut self, network: Network) -> Self {
142 self.network = network;
143 self
144 }
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149pub struct PaperWallet {
150 pub address: String,
152 pub wif: String,
154 pub network: String,
156 pub address_type: String,
158}
159
160#[derive(Debug, Clone, Copy, PartialEq, Eq)]
162pub enum AddressType {
163 P2PKH,
165 P2WPKH,
167 P2TR,
169}
170
171impl std::fmt::Display for AddressType {
172 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
173 match self {
174 AddressType::P2PKH => write!(f, "p2pkh"),
175 AddressType::P2WPKH => write!(f, "p2wpkh"),
176 AddressType::P2TR => write!(f, "p2tr"),
177 }
178 }
179}
180
181#[derive(Debug, Clone, Default)]
183pub struct Bip21Options {
184 pub amount: Option<f64>,
186 pub label: Option<String>,
188 pub message: Option<String>,
190}
191
192impl Bip21Options {
193 pub fn new() -> Self {
195 Self::default()
196 }
197
198 pub fn with_amount(mut self, amount: f64) -> Self {
200 self.amount = Some(amount);
201 self
202 }
203
204 pub fn with_label(mut self, label: impl Into<String>) -> Self {
206 self.label = Some(label.into());
207 self
208 }
209
210 pub fn with_message(mut self, message: impl Into<String>) -> Self {
212 self.message = Some(message.into());
213 self
214 }
215}