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#[macro_use]
17extern crate alloc;
18extern crate core;
19#[cfg(feature = "grpc")]
20extern crate tonic;
21
22pub use bitcoin;
23pub use lightning;
24pub use lightning_invoice;
25pub use txoo;
26
27pub mod chain;
29#[macro_use]
31pub mod util;
32#[macro_use]
34pub mod channel;
35pub mod monitor;
37#[macro_use]
39pub mod node;
40pub mod invoice;
42pub mod persist;
44pub mod policy;
46pub mod signer;
48pub mod tx;
50pub mod wallet;
52pub use hex;
54
55#[doc(hidden)]
56pub use alloc::collections::BTreeSet as OrderedSet;
57#[doc(hidden)]
58pub use alloc::rc::Rc;
59
60use bitcoin::secp256k1::PublicKey;
61use lightning::ln::chan_utils::ChannelTransactionParameters;
62
63#[cfg(not(feature = "std"))]
64mod nostd;
65
66#[doc(hidden)]
67pub mod prelude {
69 pub use alloc::{boxed::Box, string::String, vec, vec::Vec};
70
71 pub use hashbrown::HashMap as Map;
73 pub use hashbrown::HashSet as UnorderedSet;
74
75 pub use alloc::collections::BTreeMap as OrderedMap;
76 pub use alloc::collections::BTreeSet as OrderedSet;
77
78 pub use alloc::borrow::ToOwned;
79 pub use alloc::string::ToString;
80
81 #[cfg(not(all(test, feature = "shuttle")))]
82 pub use alloc::sync::{Arc, Weak};
83 #[cfg(all(test, feature = "shuttle"))]
84 pub use shuttle::sync::{Arc, Mutex, MutexGuard, Weak};
85 #[cfg(all(feature = "std", not(all(test, feature = "shuttle"))))]
86 pub use std::sync::{Mutex, MutexGuard};
87
88 #[cfg(not(feature = "std"))]
89 pub use crate::nostd::*;
90
91 #[cfg(feature = "std")]
93 pub trait SendSync: Send + Sync {}
94}
95
96#[doc(hidden)]
97pub use prelude::SendSync;
98
99use prelude::*;
100
101pub trait CommitmentPointProvider: SendSync {
104 fn get_holder_commitment_point(&self, commitment_number: u64) -> PublicKey;
106 fn get_counterparty_commitment_point(&self, commitment_number: u64) -> Option<PublicKey>;
110 fn get_transaction_parameters(&self) -> ChannelTransactionParameters;
112 fn clone_box(&self) -> Box<dyn CommitmentPointProvider>;
114}
115
116impl Clone for Box<dyn CommitmentPointProvider> {
117 fn clone(&self) -> Self {
118 (**self).clone_box()
119 }
120}
121
122#[cfg(not(feature = "std"))]
123#[allow(unused)]
124mod sync;
125
126#[cfg(test)]
127mod setup_channel_tests;
128#[cfg(test)]
129mod sign_counterparty_commitment_tests;
130#[cfg(test)]
131mod sign_counterparty_htlc_sweep_tests;
132#[cfg(test)]
133mod sign_delayed_sweep_tests;
134#[cfg(test)]
135mod sign_holder_commitment_tests;
136#[cfg(test)]
137mod sign_htlc_tx_tests;
138#[cfg(test)]
139mod sign_justice_sweep_tests;
140#[cfg(test)]
141mod sign_mutual_close_tests;
142#[cfg(test)]
143mod sign_onchain_tx_tests;
144#[cfg(test)]
145mod validate_counterparty_revocation_tests;
146#[cfg(test)]
147mod validate_holder_commitment_tests;