1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct Chain {
5 pub chain: String,
6 pub network: String,
7}
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Feature {
10 pub name: String,
11 pub is_required: bool,
12 pub is_known: bool,
13}
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct FeaturesEntry {
16 pub key: u32,
17 pub value: Feature,
18}
19#[allow(clippy::struct_excessive_bools)]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct LndInfo {
22 pub version: String,
23 pub commit_hash: String,
24 pub identity_pubkey: String,
25 pub alias: String,
26 pub color: String,
27 pub num_pending_channels: u32,
28 pub num_active_channels: u32,
29 pub num_inactive_channels: u32,
30 pub num_peers: u32,
31 pub block_height: u32,
32 pub block_hash: String,
33 pub best_header_timestamp: String,
34 pub synced_to_chain: bool,
35 pub synced_to_graph: bool,
36 pub testnet: bool,
37 pub chains: Vec<Chain>,
38 pub uris: Vec<String>,
39 pub features: std::collections::HashMap<String, Feature>,
40 pub require_htlc_interceptor: bool,
41 pub store_final_htlc_resolutions: bool,
42}
43
44impl std::str::FromStr for LndInfo {
45 type Err = serde_json::Error;
46 fn from_str(s: &str) -> Result<Self, Self::Err> {
47 serde_json::from_str(s)
48 }
49}
50
51impl TryFrom<LndInfo> for String {
52 type Error = serde_json::Error;
53 fn try_from(value: LndInfo) -> Result<Self, Self::Error> {
54 serde_json::to_string(&value)
55 }
56}