Merge pull request #1980 from TheBlueMatt/2023-01-async-utxo-lookups
[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 //!
13 //! ## Version Compatibility
14 //!
15 //! Currently this crate is compatible with nodes that were created with LDK version 0.0.113 and above.
16 //!
17 //! ## Usage Example:
18 //!
19 //! ```ignore
20 //! let tx_sync = Arc::new(EsploraSyncClient::new(
21 //!     esplora_server_url,
22 //!     Arc::clone(&some_logger),
23 //! ));
24 //!
25 //! let chain_monitor = Arc::new(ChainMonitor::new(
26 //!     Some(Arc::clone(&tx_sync)),
27 //!     Arc::clone(&some_broadcaster),
28 //!     Arc::clone(&some_logger),
29 //!     Arc::clone(&some_fee_estimator),
30 //!     Arc::clone(&some_persister),
31 //! ));
32 //!
33 //! let channel_manager = Arc::new(ChannelManager::new(
34 //!     Arc::clone(&some_fee_estimator),
35 //!     Arc::clone(&chain_monitor),
36 //!     Arc::clone(&some_broadcaster),
37 //!     Arc::clone(&some_router),
38 //!     Arc::clone(&some_logger),
39 //!     Arc::clone(&some_entropy_source),
40 //!     Arc::clone(&some_node_signer),
41 //!     Arc::clone(&some_signer_provider),
42 //!     user_config,
43 //!     chain_params,
44 //! ));
45 //!
46 //! let confirmables = vec![
47 //!     &*channel_manager as &(dyn Confirm + Sync + Send),
48 //!     &*chain_monitor as &(dyn Confirm + Sync + Send),
49 //! ];
50 //!
51 //! tx_sync.sync(confirmables).unwrap();
52 //! ```
53 //!
54 //! [`Confirm`]: lightning::chain::Confirm
55 //! [`Filter`]: lightning::chain::Filter
56 //! [`ChainMonitor`]: lightning::chain::chainmonitor::ChainMonitor
57 //! [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
58
59 // Prefix these with `rustdoc::` when we update our MSRV to be >= 1.52 to remove warnings.
60 #![deny(broken_intra_doc_links)]
61 #![deny(private_intra_doc_links)]
62
63 #![deny(missing_docs)]
64 #![deny(unsafe_code)]
65
66 #![cfg_attr(docsrs, feature(doc_auto_cfg))]
67
68 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
69 #[macro_use]
70 extern crate bdk_macros;
71
72 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
73 mod esplora;
74
75 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
76 mod common;
77
78 mod error;
79 pub use error::TxSyncError;
80
81 #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
82 pub use esplora::EsploraSyncClient;