lightning_liquidity/lib.rs
1// This file is Copyright its original authors, visible in version control
2// history.
3//
4// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7// You may not use this file except in accordance with one or both of these
8// licenses.
9#![crate_name = "lightning_liquidity"]
10
11//! The goal of this crate is to provide types and primitives to integrate a spec-compliant LSP
12//! with an LDK-based node. To this end, this crate provides client-side as well as service-side
13//! logic to implement the LSPS specifications.
14//!
15//! **Note**: Service-side support is currently considered "beta", i.e., not fully ready for
16//! production use.
17//!
18//! Currently the following specifications are supported:
19//! - [bLIP-50 / LSPS0] defines the transport protocol with the LSP over which the other protocols communicate.
20//! - [bLIP-51 / LSPS1] defines a protocol for ordering Lightning channels from an LSP. This is useful when the client needs
21//! inbound Lightning liquidity for which they are willing and able to pay in bitcoin.
22//! - [bLIP-52 / LSPS2] defines a protocol for generating a special invoice for which, when paid,
23//! an LSP will open a "just-in-time" channel. This is useful for the initial on-boarding of
24//! clients as the channel opening fees are deducted from the incoming payment, i.e., no funds are
25//! required client-side to initiate this flow.
26//! - [bLIP-55 / LSPS5] defines a protocol for sending webhook notifications to clients. This is
27//! useful for notifying clients about incoming payments, channel expiries, etc.
28//!
29//! To get started, you'll want to setup a [`LiquidityManager`] and configure it to be the
30//! [`CustomMessageHandler`] of your LDK node. You can then for example call
31//! [`LiquidityManager::lsps1_client_handler`] / [`LiquidityManager::lsps2_client_handler`], or
32//! [`LiquidityManager::lsps2_service_handler`], to access the respective client-side or
33//! service-side handlers.
34//!
35//! [`LiquidityManager`] uses an eventing system to notify the user about important updates to the
36//! protocol flow. To this end, you will need to handle events emitted via one of the event
37//! handling methods provided by [`LiquidityManager`], e.g., [`LiquidityManager::next_event`].
38//!
39//! [bLIP-50 / LSPS0]: https://github.com/lightning/blips/blob/master/blip-0050.md
40//! [bLIP-51 / LSPS1]: https://github.com/lightning/blips/blob/master/blip-0051.md
41//! [bLIP-52 / LSPS2]: https://github.com/lightning/blips/blob/master/blip-0052.md
42//! [bLIP-55 / LSPS5]: https://github.com/lightning/blips/pull/55/files
43//! [`CustomMessageHandler`]: lightning::ln::peer_handler::CustomMessageHandler
44//! [`LiquidityManager::next_event`]: crate::LiquidityManager::next_event
45#![deny(missing_docs)]
46#![deny(rustdoc::broken_intra_doc_links)]
47#![deny(rustdoc::private_intra_doc_links)]
48#![allow(bare_trait_objects)]
49#![allow(ellipsis_inclusive_range_patterns)]
50#![allow(clippy::drop_non_drop)]
51#![cfg_attr(docsrs, feature(doc_cfg))]
52#![cfg_attr(not(any(test, feature = "std")), no_std)]
53
54#[macro_use]
55extern crate alloc;
56
57mod prelude {
58 pub(crate) use lightning::util::hash_tables::*;
59}
60
61pub mod events;
62pub mod lsps0;
63pub mod lsps1;
64pub mod lsps2;
65pub mod lsps5;
66mod manager;
67pub mod message_queue;
68pub mod persist;
69#[allow(dead_code)]
70#[allow(unused_imports)]
71mod sync;
72#[cfg(test)]
73mod tests;
74pub mod utils;
75
76pub use manager::{
77 ALiquidityManager, ALiquidityManagerSync, LiquidityClientConfig, LiquidityManager,
78 LiquidityManagerSync, LiquidityServiceConfig,
79};