neo3/neo_protocol/responses/
neo_get_unspents.rs1use std::hash::{Hash, Hasher};
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
6pub struct Unspents {
7 pub address: String,
8 #[serde(rename = "balance")]
9 pub balances: Vec<Balance>,
10}
11
12#[derive(Serialize, Deserialize, Clone)]
13struct Balance {
14 #[serde(rename = "unspent")]
15 pub(crate) unspent_transactions: Vec<UnspentTransaction>,
16 #[serde(rename = "assethash")]
17 pub(crate) asset_hash: String,
18 #[serde(rename = "asset")]
19 pub(crate) asset_name: String,
20 #[serde(rename = "asset_symbol")]
21 pub(crate) asset_symbol: String,
22 pub(crate) amount: f64,
23}
24
25impl Eq for Balance {}
26
27impl PartialEq for Balance {
28 fn eq(&self, other: &Self) -> bool {
29 self.asset_hash == other.asset_hash
30 && self.asset_name == other.asset_name
31 && self.asset_symbol == other.asset_symbol
32 && self.amount == other.amount
33 }
34}
35
36impl Hash for Balance {
37 fn hash<H: Hasher>(&self, state: &mut H) {
38 self.asset_hash.hash(state);
39 self.asset_name.hash(state);
40 self.asset_symbol.hash(state);
41 }
43}
44
45#[derive(Serialize, Deserialize, Clone)]
46pub struct UnspentTransaction {
47 #[serde(rename = "txid")]
48 pub tx_id: String,
49 #[serde(rename = "n")]
50 pub index: u32,
51 pub value: f64,
52}
53impl PartialEq for UnspentTransaction {
54 fn eq(&self, other: &Self) -> bool {
55 self.tx_id == other.tx_id && self.index == other.index && self.value == other.value
56 }
57}
58
59impl Hash for UnspentTransaction {
60 fn hash<H: Hasher>(&self, state: &mut H) {
61 self.tx_id.hash(state);
62 }
65}