1#![crate_name = "lightning"]
11
12#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))]
33#![deny(rustdoc::broken_intra_doc_links)]
34#![deny(rustdoc::private_intra_doc_links)]
35#![allow(bare_trait_objects)]
39#![allow(ellipsis_inclusive_range_patterns)]
40#![cfg_attr(docsrs, feature(doc_cfg))]
41#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
42
43#[cfg(all(fuzzing, test))]
44compile_error!("Tests will always fail with cfg=fuzzing");
45
46#[macro_use]
47extern crate alloc;
48
49pub extern crate lightning_types as types;
50
51pub extern crate bitcoin;
52
53pub extern crate lightning_invoice as bolt11_invoice;
54
55#[cfg(any(test, feature = "std"))]
56extern crate core;
57
58#[cfg(any(test, feature = "_test_utils"))]
59extern crate regex;
60
61#[cfg(not(feature = "std"))]
62extern crate libm;
63
64#[cfg(ldk_bench)]
65extern crate criterion;
66
67#[cfg(all(feature = "std", test))]
68extern crate parking_lot;
69
70#[macro_use]
71pub mod util;
72
73pub mod blinded_path;
74pub mod chain;
75pub mod events;
76pub mod ln;
77pub mod offers;
78pub mod onion_message;
79pub mod routing;
80pub mod sign;
81
82pub(crate) mod crypto;
83
84pub mod io;
86
87#[doc(hidden)]
88pub mod io_extras {
92 use bitcoin::io::{self, Read, Write};
93
94 pub use bitcoin::io::sink;
96
97 pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> Result<u64, io::Error>
98 where
99 R: Read,
100 W: Write,
101 {
102 let mut count = 0;
103 let mut buf = [0u8; 64];
104
105 loop {
106 match reader.read(&mut buf) {
107 Ok(0) => break,
108 Ok(n) => {
109 writer.write_all(&buf[0..n])?;
110 count += n as u64;
111 },
112 Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {},
113 Err(e) => return Err(e.into()),
114 };
115 }
116 Ok(count)
117 }
118
119 pub fn read_to_end<D: Read>(d: &mut D) -> Result<alloc::vec::Vec<u8>, io::Error> {
120 let mut result = vec![];
121 let mut buf = [0u8; 64];
122 loop {
123 match d.read(&mut buf) {
124 Ok(0) => break,
125 Ok(n) => result.extend_from_slice(&buf[0..n]),
126 Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {},
127 Err(e) => return Err(e.into()),
128 };
129 }
130 Ok(result)
131 }
132}
133
134mod prelude {
135 #![allow(unused_imports)]
136
137 pub use alloc::{boxed::Box, collections::VecDeque, string::String, vec, vec::Vec};
138
139 pub use alloc::borrow::ToOwned;
140 pub use alloc::string::ToString;
141
142 pub use core::convert::{AsMut, AsRef, TryFrom, TryInto};
143 pub use core::default::Default;
144 pub use core::marker::Sized;
145
146 pub(crate) use crate::util::hash_tables::*;
147}
148
149#[cfg(all(not(ldk_bench), feature = "backtrace", feature = "std", test))]
150extern crate backtrace;
151
152mod sync;
153
154#[cfg(feature = "_externalize_tests")]
155lightning_macros::xtest_inventory!();