1use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
6pub enum BitcoinClientType {
7 #[serde(rename = "main")]
8 Mainnet,
9 #[serde(rename = "test")]
10 Testnet,
11 #[serde(rename = "signet")]
12 Signet,
13 #[serde(rename = "regtest")]
14 Regtest,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct BlockchainInfo {
19 pub chain: String,
20 pub blocks: u64,
21 pub headers: u64,
22 pub bestblockhash: String,
23 pub difficulty: f64,
24 pub mediantime: u64,
25 pub verificationprogress: f64,
26 pub initialblockdownload: bool,
27 pub chainwork: String,
28 pub size_on_disk: u64,
29 pub pruned: bool,
30 pub pruneheight: Option<u64>,
31 pub softforks: HashMap<String, SoftFork>,
32 pub warnings: String,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct SoftFork {
37 pub r#type: String,
38 pub active: bool,
39 pub height: Option<u64>,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct Block {
44 pub hash: String,
45 pub confirmations: i32,
46 pub strippedsize: Option<u32>,
47 pub size: u32,
48 pub weight: u32,
49 pub height: u64,
50 pub version: i32,
51 pub version_hex: String,
52 pub merkleroot: String,
53 pub tx: Vec<String>,
54 pub time: u64,
55 pub mediantime: u64,
56 pub nonce: u64,
57 pub bits: String,
58 pub difficulty: f64,
59 pub chainwork: String,
60 pub n_tx: u32,
61 pub previousblockhash: Option<String>,
62 pub nextblockhash: Option<String>,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct BlockHeader {
67 pub hash: String,
68 pub confirmations: i32,
69 pub height: u64,
70 pub version: i32,
71 pub version_hex: String,
72 pub merkleroot: String,
73 pub time: u64,
74 pub mediantime: u64,
75 pub nonce: u64,
76 pub bits: String,
77 pub difficulty: f64,
78 pub chainwork: String,
79 pub n_tx: u32,
80 pub previousblockhash: Option<String>,
81 pub nextblockhash: Option<String>,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct ChainTip {
86 pub height: u64,
87 pub hash: String,
88 pub branchlen: i32,
89 pub status: String,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct Transaction {
94 pub txid: String,
95 pub hash: String,
96 pub version: i32,
97 pub size: u32,
98 pub vsize: u32,
99 pub weight: u32,
100 pub locktime: u32,
101 pub vin: Vec<Vin>,
102 pub vout: Vec<Vout>,
103 pub hex: String,
104 pub blockhash: Option<String>,
105 pub confirmations: Option<u32>,
106 pub time: Option<u64>,
107 pub blocktime: Option<u64>,
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
111pub struct Vin {
112 pub txid: Option<String>,
113 pub vout: Option<u32>,
114 #[serde(alias = "scriptSig")]
115 pub script_sig: Option<ScriptSig>,
116 pub txinwitness: Option<Vec<String>>,
117 pub sequence: u64,
118 pub coinbase: Option<String>,
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct Vout {
123 pub value: f64,
124 pub n: u32,
125 #[serde(alias = "scriptPubKey")]
126 pub script_pub_key: ScriptPubKey,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
130pub struct ScriptSig {
131 pub asm: String,
132 pub hex: String,
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct ScriptPubKey {
137 pub asm: String,
138 pub hex: String,
139 pub req_sigs: Option<u32>,
140 pub r#type: String,
141 pub addresses: Option<Vec<String>>,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
145pub struct DecodedTransaction {
146 pub txid: String,
147 pub hash: String,
148 pub version: i32,
149 pub size: u32,
150 pub vsize: u32,
151 pub weight: u32,
152 pub locktime: u32,
153 pub vin: Vec<Vin>,
154 pub vout: Vec<Vout>,
155}
156
157#[derive(Debug, Clone, Serialize, Deserialize)]
158pub struct TxOut {
159 pub bestblock: String,
160 pub confirmations: u32,
161 pub value: f64,
162 #[serde(alias = "scriptPubKey")]
163 pub script_pub_key: ScriptPubKey,
164 pub coinbase: bool,
165}
166
167#[derive(Debug, Clone, Serialize, Deserialize)]
168pub struct TxOutSetInfo {
169 pub height: u64,
170 pub bestblock: String,
171 pub transactions: u64,
172 pub txouts: u64,
173 pub bogosize: u64,
174 pub hash_serialized_2: String,
175 pub disk_size: u64,
176 pub total_amount: f64,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
180pub struct WalletInfo {
181 pub walletname: String,
182 pub walletversion: u32,
183 pub balance: f64,
184 pub unconfirmed_balance: f64,
185 pub immature_balance: f64,
186 pub txcount: u32,
187 pub keypoololdest: u64,
188 pub keypoolsize: u32,
189 pub keypoolsize_hd_internal: u32,
190 pub unlocked_until: Option<u64>,
191 pub paytxfee: f64,
192 pub hdseedid: Option<String>,
193 pub private_keys_enabled: bool,
194 pub avoid_reuse: bool,
195 pub scanning: Option<Scanning>,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
199pub struct Scanning {
200 pub duration: u32,
201 pub progress: f64,
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
205pub struct AddressInfo {
206 pub purpose: String,
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
210pub struct ValidateAddress {
211 pub isvalid: bool,
212 pub address: String,
213 #[serde(alias = "scriptPubKey")]
214 pub script_pub_key: String,
215 pub isscript: bool,
216 pub iswitness: bool,
217 pub witness_version: Option<u32>,
218 pub witness_program: Option<String>,
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
222pub struct Utxo {
223 pub txid: String,
224 pub vout: u32,
225 pub address: Option<String>,
226 pub label: Option<String>,
227 #[serde(alias = "scriptPubKey")]
228 pub script_pub_key: String,
229 pub amount: f64,
230 pub confirmations: u32,
231 #[serde(alias = "redeemScript")]
232 pub redeem_script: Option<String>,
233 #[serde(alias = "witnessScript")]
234 pub witness_script: Option<String>,
235 pub spendable: bool,
236 pub solvable: bool,
237 pub desc: Option<String>,
238 pub safe: bool,
239}
240
241#[derive(Debug, Clone, Serialize, Deserialize)]
242pub struct NetworkInfo {
243 pub version: u32,
244 pub subversion: String,
245 pub protocolversion: u32,
246 pub localservices: String,
247 pub localrelay: bool,
248 pub timeoffset: i32,
249 pub connections: u32,
250 pub networkactive: bool,
251 pub networks: Vec<NetworkData>,
252 pub relayfee: f64,
253 pub incrementalfee: f64,
254 pub localaddresses: Vec<LocalAddress>,
255 pub warnings: String,
256}
257
258#[derive(Debug, Clone, Serialize, Deserialize)]
259pub struct NetworkData {
260 pub name: String,
261 pub limited: bool,
262 pub reachable: bool,
263 pub proxy: String,
264 pub proxy_randomize_credentials: bool,
265}
266
267#[derive(Debug, Clone, Serialize, Deserialize)]
268pub struct LocalAddress {
269 pub address: String,
270 pub port: u16,
271 pub score: u32,
272}
273
274#[derive(Debug, Clone, Serialize, Deserialize)]
275pub struct PeerInfo {
276 pub id: u32,
277 pub addr: String,
278 pub addrbind: Option<String>,
279 pub addrlocal: Option<String>,
280 pub services: String,
281 pub relaytxes: bool,
282 pub lastsend: u64,
283 pub lastrecv: u64,
284 pub bytessent: u64,
285 pub bytesrecv: u64,
286 pub conntime: u64,
287 pub timeoffset: i32,
288 pub pingtime: f64,
289 pub minping: Option<f64>,
290 pub version: u32,
291 pub subver: String,
292 pub inbound: bool,
293 pub addnode: bool,
294 pub startingheight: u32,
295 pub banscore: u32,
296 pub synced_headers: i32,
297 pub synced_blocks: i32,
298 pub inflight: Vec<u32>,
299 pub whitelisted: bool,
300 pub permissions: Vec<String>,
301 pub minfeefilter: f64,
302}
303
304#[derive(Debug, Clone, Serialize, Deserialize)]
305pub struct MempoolInfo {
306 pub loaded: bool,
307 pub size: u32,
308 pub bytes: u64,
309 pub usage: u64,
310 pub maxmempool: u64,
311 pub mempoolminfee: f64,
312 pub minrelaytxfee: f64,
313}
314
315#[derive(Debug, Clone, Serialize, Deserialize)]
316pub struct FeeEstimate {
317 pub feerate: Option<f64>,
318 pub errors: Option<Vec<String>>,
319 pub blocks: i32,
320}
321
322#[derive(Debug, Clone, Serialize, Deserialize)]
323pub struct MiningInfo {
324 pub blocks: u64,
325 pub currentblockweight: Option<u64>,
326 pub currentblocktx: Option<u64>,
327 pub difficulty: f64,
328 pub networkhashps: f64,
329 pub pooledtx: u64,
330 pub chain: String,
331 pub warnings: String,
332}
333
334#[derive(Debug, Clone, Serialize, Deserialize)]
335pub struct CreateTxInput {
336 pub txid: String,
337 pub vout: u32,
338 pub sequence: Option<u32>,
339}
340
341#[derive(Debug, Clone, Serialize, Deserialize)]
342pub struct SignedTransaction {
343 pub hex: String,
344 pub complete: bool,
345 pub errors: Option<Vec<SigningError>>,
346}
347
348#[derive(Debug, Clone, Serialize, Deserialize)]
349pub struct SigningError {
350 pub txid: String,
351 pub vout: u32,
352 #[serde(alias = "scriptSig")]
353 pub script_sig: String,
354 pub sequence: u64,
355 pub error: String,
356}
357
358#[derive(Debug, Clone, Serialize, Deserialize)]
359pub struct BlockStats {
360 pub avgfee: u64,
361 pub avgfeerate: u64,
362 pub avgtxsize: u64,
363 pub blockhash: String,
364 pub feerate_percentiles: Vec<u64>,
365 pub height: u64,
366 pub ins: u64,
367 pub maxfee: u64,
368 pub maxfeerate: u64,
369 pub maxtxsize: u64,
370 pub medianfee: u64,
371 pub mediantime: u64,
372 pub mediantxsize: u64,
373 pub minfee: u64,
374 pub minfeerate: u64,
375 pub mintxsize: u64,
376 pub outs: u64,
377 pub subsidy: u64,
378 pub swtotal_size: u64,
379 pub swtotal_weight: u64,
380 pub swtxs: u64,
381 pub time: u64,
382 pub total_out: u64,
383 pub total_size: u64,
384 pub total_weight: u64,
385 pub totalfee: u64,
386 pub txs: u64,
387 pub utxo_increase: i64,
388 pub utxo_size_inc: i64,
389}