1#![crate_name = "lightning_signer"]
2
3#![forbid(unsafe_code)]
7#![allow(bare_trait_objects)]
8#![allow(ellipsis_inclusive_range_patterns)]
9#![warn(rustdoc::broken_intra_doc_links)]
10#![warn(missing_docs)]
11#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
12
13#[cfg(not(any(feature = "std", feature = "no-std")))]
14compile_error!("at least one of the `std` or `no-std` features must be enabled");
15
16#[cfg(not(feature = "std"))]
17extern crate core2;
18
19#[macro_use]
20extern crate alloc;
21extern crate core;
22#[cfg(feature = "grpc")]
23extern crate tonic;
24
25pub use bitcoin;
26pub use lightning;
27pub use lightning_invoice;
28pub use txoo;
29
30pub mod chain;
32#[macro_use]
34pub mod util;
35#[macro_use]
37pub mod channel;
38pub mod monitor;
40#[macro_use]
42pub mod node;
43pub mod invoice;
45pub mod persist;
47pub mod policy;
49pub mod signer;
51pub mod tx;
53pub mod wallet;
55pub use hex;
57
58#[cfg(not(feature = "std"))]
59mod io_extras {
60 pub use core2::io::{self, Error};
61
62 pub struct Sink {
64 _priv: (),
65 }
66
67 pub const fn sink() -> Sink {
69 Sink { _priv: () }
70 }
71
72 impl core2::io::Write for Sink {
73 #[inline]
74 fn write(&mut self, buf: &[u8]) -> core2::io::Result<usize> {
75 Ok(buf.len())
76 }
77
78 #[inline]
79 fn flush(&mut self) -> core2::io::Result<()> {
80 Ok(())
81 }
82 }
83}
84
85#[cfg(feature = "std")]
86mod io_extras {
87 pub use std::io::{self, sink, Error};
88}
89
90pub use io_extras::io;
91
92#[doc(hidden)]
93pub use alloc::collections::BTreeSet as OrderedSet;
94#[doc(hidden)]
95pub use alloc::rc::Rc;
96#[doc(hidden)]
97pub use alloc::sync::{Arc, Weak};
98
99use bitcoin::secp256k1::PublicKey;
100use lightning::ln::chan_utils::ChannelTransactionParameters;
101
102#[cfg(not(feature = "std"))]
103mod nostd;
104
105pub mod prelude {
107 pub use alloc::{boxed::Box, string::String, vec, vec::Vec};
108
109 pub use hashbrown::HashMap as Map;
111 pub use hashbrown::HashSet as UnorderedSet;
112
113 pub use alloc::collections::BTreeMap as OrderedMap;
114 pub use alloc::collections::BTreeSet as OrderedSet;
115
116 pub use alloc::borrow::ToOwned;
117 pub use alloc::string::ToString;
118
119 #[cfg(not(feature = "std"))]
120 pub use crate::nostd::*;
121
122 #[cfg(feature = "std")]
123 pub use std::sync::{Mutex, MutexGuard};
124
125 #[cfg(feature = "std")]
127 pub trait SendSync: Send + Sync {}
128}
129
130#[doc(hidden)]
131pub use prelude::SendSync;
132
133use prelude::*;
134
135#[cfg(feature = "std")]
136mod sync {
137 pub use ::std::sync::{Arc, Weak};
138}
139
140pub trait CommitmentPointProvider: SendSync {
143 fn get_holder_commitment_point(&self, commitment_number: u64) -> PublicKey;
145 fn get_counterparty_commitment_point(&self, commitment_number: u64) -> Option<PublicKey>;
149 fn get_transaction_parameters(&self) -> ChannelTransactionParameters;
151 fn clone_box(&self) -> Box<dyn CommitmentPointProvider>;
153}
154
155impl Clone for Box<dyn CommitmentPointProvider> {
156 fn clone(&self) -> Self {
157 (**self).clone_box()
158 }
159}
160
161#[cfg(not(feature = "std"))]
162#[allow(unused)]
163mod sync;
164
165#[cfg(test)]
166mod setup_channel_tests;
167#[cfg(test)]
168mod sign_counterparty_commitment_tests;
169#[cfg(test)]
170mod sign_counterparty_htlc_sweep_tests;
171#[cfg(test)]
172mod sign_delayed_sweep_tests;
173#[cfg(test)]
174mod sign_holder_commitment_tests;
175#[cfg(test)]
176mod sign_htlc_tx_tests;
177#[cfg(test)]
178mod sign_justice_sweep_tests;
179#[cfg(test)]
180mod sign_mutual_close_tests;
181#[cfg(test)]
182mod sign_onchain_tx_tests;
183#[cfg(test)]
184mod validate_counterparty_revocation_tests;
185#[cfg(test)]
186mod validate_holder_commitment_tests;