use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Chain {
pub chain: String,
pub network: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Feature {
pub name: String,
pub is_required: bool,
pub is_known: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FeaturesEntry {
pub key: u32,
pub value: Feature,
}
#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LndInfo {
pub version: String,
pub commit_hash: String,
pub identity_pubkey: String,
pub alias: String,
pub color: String,
pub num_pending_channels: u32,
pub num_active_channels: u32,
pub num_inactive_channels: u32,
pub num_peers: u32,
pub block_height: u32,
pub block_hash: String,
pub best_header_timestamp: String,
pub synced_to_chain: bool,
pub synced_to_graph: bool,
pub testnet: bool,
pub chains: Vec<Chain>,
pub uris: Vec<String>,
pub features: std::collections::HashMap<String, Feature>,
pub require_htlc_interceptor: bool,
pub store_final_htlc_resolutions: bool,
}
impl std::str::FromStr for LndInfo {
type Err = serde_json::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
serde_json::from_str(s)
}
}
impl TryFrom<LndInfo> for String {
type Error = serde_json::Error;
fn try_from(value: LndInfo) -> Result<Self, Self::Error> {
serde_json::to_string(&value)
}
}