clightningrpc_plugin/commands/
types.rs

1//! contains types that are essential to implement the plugin library.
2//!
3//! author: https://github.com/vincenzopalazzo
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Clone, Eq, Hash, PartialEq, Serialize, Debug)]
8/// Type to define metadata for custom RPC Methods
9pub struct RPCMethodInfo {
10    pub name: String,
11    pub usage: String,
12    pub description: String,
13    pub long_description: String,
14    pub deprecated: bool,
15}
16
17#[derive(Clone, PartialEq, Eq, Hash, Serialize, Debug)]
18/// Type to define metadata for custom RPC Hooks
19pub struct RPCHookInfo {
20    pub name: String,
21    pub before: Option<Vec<String>>,
22    pub after: Option<Vec<String>>,
23}
24
25#[derive(Deserialize, Clone, Debug)]
26/// Type to define attributes for the plugin's init method
27pub(crate) struct InitConf {
28    pub options: HashMap<String, serde_json::Value>,
29    pub configuration: CLNConf,
30}
31
32#[derive(Deserialize, Debug, Clone)]
33/// Type to define the configuration options for the plugin's init method
34pub struct CLNConf {
35    #[serde(rename = "lightning-dir")]
36    pub lightning_dir: String,
37    #[serde(rename = "rpc-file")]
38    pub rpc_file: String,
39    pub startup: bool,
40    pub network: String,
41    pub feature_set: HashMap<String, String>,
42    pub proxy: Option<ProxyInfo>,
43    #[serde(rename = "torv3-enabled")]
44    pub torv3_enabled: Option<bool>,
45    pub always_use_proxy: Option<bool>,
46}
47
48#[derive(Deserialize, Clone, Debug)]
49/// Type to define the network information for the plugin's configuration
50pub struct ProxyInfo {
51    #[serde(alias = "type")]
52    pub tup: String,
53    pub address: String,
54    pub port: i64,
55}