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