1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#[derive(Deserialize, Serialize, Debug)]
pub enum AddNodeCommand {
    #[serde(rename = "add")]
    Add,
    #[serde(rename = "remove")]
    Remove,
    #[serde(rename = "onetry")]
    Onetry
}

#[derive(Deserialize, Serialize, Debug)]
pub struct AddedNodeInfo {
    pub addednode: String, // is an IP
    pub connected: Option<bool>,
    pub addresses: Option<Vec<ConnectedAddress>>
}

#[derive(Deserialize, Serialize, Debug)]
pub struct ConnectedAddress {
    pub address: String, //is an IP
    pub connected: String
}

#[derive(Deserialize, Serialize, Debug)]
pub struct DeprecationInfo {
    pub version: u64,
    pub subversion: String,
    pub deprecationheight: u64
}

#[derive(Deserialize, Serialize, Debug)]
pub struct NetTotals {
    pub totalbytesrecv: u64,
    pub totalbytessent: u64,
    pub timemillis: u64
}

#[derive(Deserialize, Serialize, Debug)]
pub struct NetworkInfo {
    pub version: u64,
    pub subversion: String,
    pub protocolversion: u64,
    pub localservices: String,
    pub timeoffset: i32,
    pub connections: u32,
    pub networks: Vec<NetworkVersion>,
    pub relayfee: f64,
    pub localaddresses: Vec<Option<LocalAddress>>,
    pub warnings: String
}

#[derive(Deserialize, Serialize, Debug)]
pub struct NetworkVersion {
    pub name: String,
    pub limited: bool,
    pub reachable: bool,
    pub proxy: String,
    pub proxy_randomize_credentials: bool
}

#[derive(Deserialize, Serialize, Debug)]
pub struct LocalAddress {
    pub address: String,
    pub port: u16,
    pub score: u64
}

#[derive(Deserialize, Serialize, Debug)]
pub struct Peer {
    pub id: u32,
    pub addr: String,
    pub addrlocal: String,
    pub services: String,
    pub lastsend: u64,
    pub lastrecv: u64,
    pub bytessent: u64,
    pub bytesrecv: u64,
    pub conntime: u64,
    pub timeoffset: i32,
    pub pingtime: f64,
    pub version: u32,
    pub subver: String,
    pub inbound: bool,
    pub startingheight: u64,
    pub banscore: u8,
    pub synced_headers: u64,
    pub synced_blocks: u64,
    pub inflight: Vec<Option<u64>>,
    pub whitelisted: bool
}

#[derive(Deserialize, Serialize, Debug)]
pub struct BannedNode {
    pub address: String,
    pub banned_until: u64
}