1use {
2 crate::{transaction::TransactionStatus, RuneAmount, SerializedOutPoint, SpentStatus, TxOut},
3 bitcoin::Txid,
4 serde::{Deserialize, Serialize},
5};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct AddressData {
9 pub value: u64,
10 pub runes: Vec<RuneAmount>,
11 pub outputs: Vec<AddressTxOut>,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct AddressTxOut {
16 pub txid: Txid,
17 pub vout: u32,
18 pub value: u64,
19 pub runes: Vec<RuneAmount>,
20 pub risky_runes: Vec<RuneAmount>,
21 pub spent: SpentStatus,
22 pub status: TransactionStatus,
23 pub size: u64,
24 pub weight: u64,
25}
26
27impl From<(SerializedOutPoint, TxOut, TransactionStatus)> for AddressTxOut {
28 fn from((outpoint, tx_out, status): (SerializedOutPoint, TxOut, TransactionStatus)) -> Self {
29 Self {
30 txid: outpoint.to_txid(),
31 vout: outpoint.vout(),
32 value: tx_out.value,
33 runes: tx_out.runes,
34 risky_runes: tx_out.risky_runes,
35 spent: tx_out.spent,
36 status,
37 size: 0,
38 weight: 0,
39 }
40 }
41}
42
43impl From<(SerializedOutPoint, TxOut, TransactionStatus, u64, u64)> for AddressTxOut {
44 fn from(
45 (outpoint, tx_out, status, size, weight): (
46 SerializedOutPoint,
47 TxOut,
48 TransactionStatus,
49 u64,
50 u64,
51 ),
52 ) -> Self {
53 Self {
54 txid: outpoint.to_txid(),
55 vout: outpoint.vout(),
56 value: tx_out.value,
57 runes: tx_out.runes,
58 risky_runes: tx_out.risky_runes,
59 spent: tx_out.spent,
60 status,
61 size,
62 weight,
63 }
64 }
65}