Move some additional test macros into functions
[rust-lightning] / lightning-transaction-sync / src / lib.rs
1 //! Provides utilities for syncing LDK via the transaction-based [`Confirm`] interface.
2 //!
3 //! The provided synchronization clients need to be registered with a [`ChainMonitor`] via the
4 //! [`Filter`] interface. Then, the respective `fn sync` needs to be called with the [`Confirm`]
5 //! implementations to be synchronized, i.e., usually instances of [`ChannelManager`] and
6 //! [`ChainMonitor`].
7 //!
8 //! ## Features and Backend Support
9 //!
10 //!- `esplora-blocking` enables syncing against an Esplora backend based on a blocking client.
11 //!- `esplora-async` enables syncing against an Esplora backend based on an async client.
12 //!- `esplora-async-https` enables the async Esplora client with support for HTTPS.
13 //!
14 //! ## Version Compatibility
15 //!
16 //! Currently this crate is compatible with nodes that were created with LDK version 0.0.113 and above.
17 //!
18 //! ## Usage Example:
19 //!
20 //! ```ignore
21 //! let tx_sync = Arc::new(EsploraSyncClient::new(
22 //!     esplora_server_url,
23 //!     Arc::clone(&some_logger),
24 //! ));
25 //!
26 //! let chain_monitor = Arc::new(ChainMonitor::new(
27 //!     Some(Arc::clone(&tx_sync)),
28 //!     Arc::clone(&some_broadcaster),
29 //!     Arc::clone(&some_logger),
30 //!     Arc::clone(&some_fee_estimator),
31 //!     Arc::clone(&some_persister),
32 //! ));
33 //!
34 //! let channel_manager = Arc::new(ChannelManager::new(
35 //!     Arc::clone(&some_fee_estimator),
36 //!     Arc::clone(&chain_monitor),
37 //!     Arc::clone(&some_broadcaster),
38 //!     Arc::clone(&some_router),
39 //!     Arc::clone(&some_logger),
40 //!     Arc::clone(&some_entropy_source),
41 //!     Arc::clone(&some_node_signer),
42 //!     Arc::clone(&some_signer_provider),
43 //!     user_config,
44 //!     chain_params,
45 //! ));
46 //!
47 //! let confirmables = vec![
48 //!     &*channel_manager as &(dyn Confirm + Sync + Send),
49 //!     &*chain_monitor as &(dyn Confirm + Sync + Send),
50 //! ];
51 //!
52 //! tx_sync.sync(confirmables).unwrap();
53 //! ```
54 //!
55 //! [`Confirm`]: lightning::chain::Confirm
56 //! [`Filter`]: lightning::chain::Filter
57 //! [`ChainMonitor`]: lightning::chain::chainmonitor::ChainMonitor
58 //! [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
59
60 // Prefix these with `rustdoc::` when we update our MSRV to be >= 1.52 to remove warnings.
61 #![deny(broken_intra_doc_links)]
62 #![deny(private_intra_doc_links)]
63
64 #![deny(missing_docs)]
65 #![deny(unsafe_code)]
66
67 #![cfg_attr(docsrs, feature(doc_auto_cfg))]
68
69 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
70 #[macro_use]
71 extern crate bdk_macros;
72
73 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
74 mod esplora;
75
76 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
77 mod common;
78
79 mod error;
80 pub use error::TxSyncError;
81
82 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
83 pub use esplora::EsploraSyncClient;