1#![allow(missing_docs)]
16use serde_json;
18use std::collections::HashMap;
19use std::net::{Ipv4Addr, Ipv6Addr};
20
21use crate::common;
22use crate::common::MSat;
23
24#[derive(Debug, Clone, Deserialize, Serialize)]
26#[serde(tag = "type", rename_all = "lowercase")]
27pub enum NetworkAddress {
28 Ipv4 {
29 address: Ipv4Addr,
30 port: u16,
31 },
32 Ipv6 {
33 address: Ipv6Addr,
34 port: u16,
35 },
36 Torv2 {
37 address: String,
38 port: u16,
39 },
40 Torv3 {
41 address: String,
42 port: u16,
43 },
44}
45
46#[derive(Debug, Clone, Deserialize, Serialize)]
48pub struct GetInfo {
49 pub id: String,
50 pub alias: String,
51 pub color: String,
52 pub num_peers: u64,
53 pub num_pending_channels: u64,
54 pub num_active_channels: u64,
55 pub num_inactive_channels: u64,
56 pub address: Vec<NetworkAddress>,
57 pub binding: Vec<NetworkAddress>,
58 pub version: String,
59 pub blockheight: u64,
60 pub fees_collected_msat: MSat,
61 pub network: String,
62 #[serde(rename = "lightning-dir")]
63 pub ligthning_dir: String,
64 pub warning_bitcoind_sync: Option<String>,
65 pub warning_lightningd_sync: Option<String>,
66}
67
68#[derive(Debug, Clone, Deserialize, Serialize)]
69pub struct FeeRatesInner {
70 pub urgent: Option<u64>,
71 pub normal: Option<u64>,
72 pub slow: Option<u64>,
73 pub opening: u64,
74 pub mutual_close: u64,
75 pub unilateral_close: u64,
76 pub delayed_to_us: u64,
77 pub htlc_resolution: u64,
78 pub penalty: u64,
79 pub min_acceptable: u64,
80 pub max_acceptable: u64,
81}
82
83#[derive(Debug, Clone, Deserialize, Serialize)]
84pub struct FeeRatesOnchain {
85 pub opening_channel_satoshis: u64,
86 pub mutual_close_satoshis: u64,
87 pub unilateral_close_satoshis: u64,
88 pub htlc_timeout_satoshis: u64,
89 pub htlc_success_satoshis: u64,
90}
91
92#[derive(Debug, Clone, Deserialize, Serialize)]
94pub struct FeeRates {
95 pub perkb: Option<FeeRatesInner>,
96 pub perkw: Option<FeeRatesInner>,
97 pub warning: Option<String>,
98 pub onchain_fee_estimates: Option<FeeRatesOnchain>,
99}
100
101#[derive(Debug, Clone, Deserialize, Serialize)]
103pub struct ListNodesItem {
104 pub nodeid: String,
105 pub alias: Option<String>,
106 pub color: Option<String>,
107 pub last_timestamp: Option<u64>,
108 pub features: Option<String>,
109 pub addresses: Option<Vec<NetworkAddress>>,
110}
111
112#[derive(Debug, Clone, Deserialize, Serialize)]
114pub struct ListNodes {
115 pub nodes: Vec<ListNodesItem>,
116}
117
118#[derive(Debug, Clone, Deserialize, Serialize)]
120pub struct ListChannelsItem {
121 pub source: String,
122 pub destination: String,
123 pub short_channel_id: String,
124 pub public: bool,
125 pub amount_msat: MSat,
126 pub message_flags: u64,
127 pub channel_flags: u64,
128 pub active: bool,
129 pub last_update: u64,
130 pub base_fee_millisatoshi: u64,
131 pub fee_per_millionth: u64,
132 pub delay: u64,
133 pub htlc_minimum_msat: MSat,
134 pub htlc_maximum_msat: MSat,
135 pub features: String,
136}
137
138#[derive(Debug, Clone, Deserialize, Serialize)]
140pub struct ListChannels {
141 pub channels: Vec<ListChannelsItem>,
142}
143
144#[derive(Debug, Clone, Deserialize, Serialize)]
146pub struct HelpItem {
147 pub command: String,
148 pub category: String,
149 pub description: String,
150 pub verbose: String,
151}
152
153#[derive(Debug, Clone, Deserialize, Serialize)]
155pub struct Help {
156 pub help: Option<Vec<HelpItem>>,
157}
158
159#[derive(Debug, Clone, Deserialize, Serialize)]
161pub struct LogEntry {
162 #[serde(rename = "type")]
163 pub type_: String,
164 pub num_skipped: Option<u64>,
165 pub time: Option<String>,
166 pub node_id: Option<String>,
167 pub source: Option<String>,
168 pub log: Option<String>,
169 pub data: Option<String>,
170}
171
172#[derive(Debug, Clone, Deserialize, Serialize)]
174pub struct GetLog {
175 pub created_at: String,
176 pub bytes_used: u64,
177 pub bytes_max: u64,
178 pub log: Vec<LogEntry>,
179}
180
181pub type ListConfigs = HashMap<String, serde_json::Value>;
183
184#[derive(Debug, Clone, Deserialize, Serialize)]
186pub struct Htlc {
187 pub direction: String,
188 pub id: u64,
189 pub amount_msat: MSat,
190 pub expiry: u64,
191 pub payment_hash: String,
192 pub state: String,
193 pub local_trimmed: Option<bool>,
194}
195
196#[derive(Debug, Clone, Deserialize, Serialize)]
198pub struct Channel {
199 pub state: String,
200 pub scratch_txid: Option<String>,
201 pub owner: Option<String>,
202 pub short_channel_id: Option<String>,
203 pub direction: Option<u64>,
204 pub channel_id: String,
205 pub funding_txid: String,
206 pub close_to_addr: Option<String>,
207 pub close_to: Option<String>,
208 pub private: bool,
209 pub funding_msat: HashMap<String, MSat>,
210 pub to_us_msat: MSat,
211 pub min_to_us_msat: MSat,
212 pub max_to_us_msat: MSat,
213 pub total_msat: MSat,
214 pub dust_limit_msat: MSat,
215 pub max_total_htlc_in_msat: MSat, pub their_reserve_msat: MSat,
217 pub our_reserve_msat: MSat,
218 pub spendable_msat: MSat,
219 pub receivable_msat: MSat,
220 pub minimum_htlc_in_msat: MSat,
221 pub their_to_self_delay: u64,
222 pub our_to_self_delay: u64,
223 pub max_accepted_htlcs: u64,
224 pub status: Vec<String>,
225 pub in_payments_offered: u64,
226 pub in_offered_msat: MSat,
227 pub in_payments_fulfilled: u64,
228 pub in_fulfilled_msat: MSat,
229 pub out_payments_offered: u64,
230 pub out_offered_msat: MSat,
231 pub out_payments_fulfilled: u64,
232 pub out_fulfilled_msat: MSat,
233 pub htlcs: Vec<Htlc>,
234}
235
236#[derive(Debug, Clone, Deserialize, Serialize)]
238pub struct Peer {
239 pub id: String,
240 pub connected: bool,
241 pub netaddr: Option<Vec<String>>,
242 pub features: Option<String>,
243 pub channels: Vec<Channel>,
244 pub log: Option<Vec<LogEntry>>,
245}
246
247#[derive(Debug, Clone, Deserialize, Serialize)]
249pub struct ListPeers {
250 pub peers: Vec<Peer>,
251}
252
253#[derive(Debug, Clone, Deserialize, Serialize)]
255pub struct ListInvoice {
256 pub label: String,
257 pub bolt11: String,
258 pub payment_hash: String,
259 pub amount_msat: Option<MSat>,
260 pub status: String,
261 pub pay_index: Option<u64>,
262 pub amount_received_msat: Option<MSat>,
263 pub paid_at: Option<u64>,
264 pub payment_preimage: Option<String>,
265 pub description: Option<String>,
266 pub expires_at: u64,
267}
268
269#[derive(Debug, Clone, Deserialize, Serialize)]
271pub struct ListInvoices {
272 pub invoices: Vec<ListInvoice>,
273}
274
275#[derive(Debug, Clone, Deserialize, Serialize)]
277pub struct Invoice {
278 pub payment_hash: String,
279 pub expires_at: u64,
280 pub bolt11: String,
281}
282
283pub type DelInvoice = ListInvoice;
285
286#[derive(Debug, Clone, Deserialize, Serialize)]
288pub struct DelExpiredInvoice {}
289
290#[derive(Debug, Clone, Deserialize, Serialize)]
292pub struct AutoCleanInvoice {}
293
294pub type WaitAnyInvoice = ListInvoice;
296
297pub type WaitInvoice = ListInvoice;
299
300#[derive(Debug, Clone, Deserialize, Serialize)]
302pub struct FailureItem {
303 pub message: String,
304 #[serde(rename = "type")]
305 pub type_: String,
306 pub erring_index: u64,
307 pub failcode: u64,
308 pub erring_node: String,
309 pub erring_channel: String,
310 pub channel_update: Option<String>,
311 pub route: Vec<common::RouteItem>,
312}
313
314#[derive(Debug, Clone, Deserialize, Serialize)]
316pub struct Pay {
317 pub id: u64,
318 pub payment_hash: String,
319 pub destination: String,
320 pub msatoshi: u64,
321 pub msatoshi_sent: u64,
322 pub created_at: u64,
323 pub status: String,
324 pub payment_preimage: String,
325 pub description: String,
326 pub getroute_tries: u64,
327 pub sendpay_tries: u64,
328 pub route: Vec<common::RouteItem>,
329 pub failures: Vec<FailureItem>,
330}
331
332#[derive(Debug, Clone, Deserialize, Serialize)]
334pub struct SendPay {
335 pub message: Option<String>,
336
337 pub id: u64,
338 pub payment_hash: String,
339 pub partid: Option<u64>,
340 pub destination: Option<String>,
341 pub amount_msat: Option<MSat>,
342 pub amount_sent_msat: MSat,
343 pub created_at: u64,
344 pub status: String,
345 pub payment_preimage: Option<String>,
346 pub description: Option<String>,
347 pub bolt11: Option<String>,
348 pub erroronion: Option<String>,
349
350 pub onionreply: Option<String>,
351 pub erring_index: Option<u64>,
352 pub failcode: Option<u64>,
353 pub failcodename: Option<String>,
354 pub erring_node: Option<String>,
355 pub erring_channel: Option<String>,
356 pub erring_direction: Option<u64>,
357 pub raw_message: Option<String>,
358}
359
360#[derive(Debug, Clone, Deserialize, Serialize)]
362pub struct ListSendPaysItem {
363 pub id: u64,
364 pub payment_hash: String,
365 pub partid: Option<u64>,
366 pub destination: Option<String>,
367 pub amount_msat: Option<MSat>,
368 pub amount_sent_msat: MSat,
369 pub created_at: u64,
370 pub status: String,
371 pub payment_preimage: Option<String>,
372 pub description: Option<String>,
373 pub bolt11: Option<String>,
374 pub erroronion: Option<String>,
375}
376
377pub type WaitSendPay = ListSendPaysItem;
379
380#[derive(Debug, Clone, Deserialize, Serialize)]
382pub struct ListSendPays {
383 pub payments: Vec<ListSendPaysItem>,
384}
385
386#[derive(Debug, Clone, Deserialize, Serialize)]
388pub struct Fallback {
389 #[serde(rename = "type")]
390 pub type_: String,
391 pub addr: String,
392 pub hex: String,
393}
394
395#[derive(Debug, Clone, Deserialize, Serialize)]
397pub struct DecodePayRoute {
398 pub pubkey: String,
399 pub short_channel_id: String,
400 pub fee_base_msat: u64,
401 pub fee_proportional_millionths: u64,
402 pub cltv_expiry_delta: u64,
403}
404
405#[derive(Debug, Clone, Deserialize, Serialize)]
407pub struct Extra {
408 pub tag: String,
409 pub data: String,
410}
411
412#[derive(Debug, Clone, Deserialize, Serialize)]
414pub struct DecodePay {
415 pub currency: String,
416 pub created_at: u64,
417 pub expiry: u64,
418 pub payee: String,
419 pub amount_msat: Option<MSat>,
420 pub description: Option<String>,
421 pub description_hash: Option<String>,
422 pub min_final_cltv_expiry: u64,
423 pub payment_secret: Option<String>,
424 pub features: Option<String>,
425 pub fallbacks: Option<Vec<Fallback>>,
426 pub routes: Option<Vec<Vec<DecodePayRoute>>>,
427 pub extra: Option<Vec<Extra>>,
428 pub payment_hash: String,
429 pub signature: String,
430}
431
432#[derive(Debug, Clone, Deserialize, Serialize)]
434pub struct GetRoute {
435 pub route: Vec<common::RouteItem>,
436}
437
438#[derive(Debug, Clone, Deserialize, Serialize)]
440pub struct Connect {
441 pub id: String,
442 pub features: String,
443}
444
445#[derive(Debug, Clone, Deserialize, Serialize)]
447pub struct Disconnect {}
448
449#[derive(Debug, Clone, Deserialize, Serialize)]
451pub struct FundChannel {
452 pub tx: String,
453 pub txid: String,
454 pub channel_id: String,
455}
456
457#[derive(Debug, Clone, Deserialize, Serialize)]
459pub struct Close {
460 pub tx: String,
461 pub txid: String,
462 #[serde(rename = "type")]
463 pub type_: String,
464}
465
466#[derive(Debug, Clone, Deserialize, Serialize)]
468pub struct Ping {
469 pub totlen: u64,
470}
471
472#[derive(Debug, Clone, Deserialize, Serialize)]
474pub struct ListFundsOutput {
475 pub txid: String,
476 pub output: u64,
477 pub amount_msat: MSat,
478 pub address: String,
479 pub status: String,
480}
481
482#[derive(Debug, Clone, Deserialize, Serialize)]
484pub struct ListFundsChannel {
485 pub peer_id: String,
486 pub connected: bool,
487 pub short_channel_id: Option<String>,
488 pub our_amount_msat: MSat,
489 pub amount_msat: MSat,
490 pub funding_txid: String,
491 pub funding_output: u64,
492}
493
494#[derive(Debug, Clone, Deserialize, Serialize)]
496pub struct ListFunds {
497 pub outputs: Vec<ListFundsOutput>,
498 pub channels: Vec<ListFundsChannel>,
499}
500
501#[derive(Debug, Clone, Deserialize, Serialize)]
503pub struct Withdraw {
504 pub tx: String,
505 pub txid: String,
506}
507
508#[derive(Debug, Clone, Deserialize, Serialize)]
510pub struct NewAddr {
511 pub address: Option<String>,
512 pub bech32: Option<String>,
513 #[serde(rename = "p2sh-segwit")]
514 pub p2sh_segwit: Option<String>,
515}
516
517pub type Stop = String;