Skip to content

Support client_trusts_lsp on LSPS2 #3838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions fuzz/src/lsps_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub fn do_test(data: &[u8]) {
Arc::clone(&keys_manager),
Arc::clone(&manager),
None::<Arc<dyn Filter + Send + Sync>>,
Arc::clone(&tx_broadcaster),
None,
None,
None,
Expand Down
4 changes: 3 additions & 1 deletion lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ use futures_util::{dummy_waker, Joiner, OptionalSelector, Selector, SelectorOutp
/// # type P2PGossipSync<UL> = lightning::routing::gossip::P2PGossipSync<Arc<NetworkGraph>, Arc<UL>, Arc<Logger>>;
/// # type ChannelManager<B, F, FE> = lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor<B, F, FE>, B, FE, Logger>;
/// # type OnionMessenger<B, F, FE> = lightning::onion_message::messenger::OnionMessenger<Arc<lightning::sign::KeysManager>, Arc<lightning::sign::KeysManager>, Arc<Logger>, Arc<ChannelManager<B, F, FE>>, Arc<lightning::onion_message::messenger::DefaultMessageRouter<Arc<NetworkGraph>, Arc<Logger>, Arc<lightning::sign::KeysManager>>>, Arc<ChannelManager<B, F, FE>>, lightning::ln::peer_handler::IgnoringMessageHandler, lightning::ln::peer_handler::IgnoringMessageHandler, lightning::ln::peer_handler::IgnoringMessageHandler>;
/// # type LiquidityManager<B, F, FE> = lightning_liquidity::LiquidityManager<Arc<lightning::sign::KeysManager>, Arc<lightning::sign::KeysManager>, Arc<ChannelManager<B, F, FE>>, Arc<F>, Arc<DefaultTimeProvider>>;
/// # type LiquidityManager<B, F, FE> = lightning_liquidity::LiquidityManager<Arc<lightning::sign::KeysManager>, Arc<lightning::sign::KeysManager>, Arc<ChannelManager<B, F, FE>>, Arc<F>, Arc<DefaultTimeProvider>, Arc<B>>;
/// # type Scorer = RwLock<lightning::routing::scoring::ProbabilisticScorer<Arc<NetworkGraph>, Arc<Logger>>>;
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, StoreSync>;
/// # type OutputSweeper<B, D, FE, F, O> = lightning::util::sweep::OutputSweeper<Arc<B>, Arc<D>, Arc<FE>, Arc<F>, Arc<Store>, Arc<Logger>, Arc<O>>;
Expand Down Expand Up @@ -1796,6 +1796,7 @@ mod tests {
Arc<ChannelManager>,
Arc<dyn Filter + Sync + Send>,
Arc<DefaultTimeProvider>,
Arc<test_utils::TestBroadcaster>,
>;

struct Node {
Expand Down Expand Up @@ -2247,6 +2248,7 @@ mod tests {
Arc::clone(&keys_manager),
Arc::clone(&manager),
None,
Arc::clone(&tx_broadcaster),
None,
None,
None,
Expand Down
19 changes: 19 additions & 0 deletions lightning-liquidity/src/lsps2/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,23 @@ pub enum LSPS2ServiceEvent {
/// The intercept short channel id to use in the route hint.
intercept_scid: u64,
},
/// You should broadcast the funding transaction to finalize opening the channel.
///
/// This event is emitted once both [`Event::FundingTxBroadcastSafe`] and the
/// corresponding payment has been successfully claimed.
///
/// Call [`LSPS2ServiceHandler::broadcast_transaction`] with the funding
/// transaction to publish it on-chain.
///
/// [`Event::FundingTxBroadcastSafe`]: lightning::events::Event::FundingTxBroadcastSafe
/// [`Event::PaymentClaimed`]: lightning::events::Event::PaymentClaimed
/// [`LSPS2ServiceHandler::broadcast_transaction`]: crate::lsps2::service::LSPS2ServiceHandler::broadcast_transaction
BroadcastFundingTransaction {
/// The node id of the counterparty.
counterparty_node_id: PublicKey,
/// The user channel id that was used to open the channel.
user_channel_id: u128,
/// The funding transaction to broadcast.
funding_tx: bitcoin::Transaction,
},
}
9 changes: 8 additions & 1 deletion lightning-liquidity/src/lsps2/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ pub struct LSPS2BuyResponse {
pub jit_channel_scid: LSPS2InterceptScid,
/// The locktime expiry delta the lsp requires.
pub lsp_cltv_expiry_delta: u32,
/// A flag that indicates who is trusting who.
/// Trust model flag (default: false).
///
/// false => "LSP trusts client": LSP immediately (or as soon as safe) broadcasts the
/// funding transaction; client may wait for broadcast / confirmations
/// before revealing the preimage.
/// true => "Client trusts LSP": LSP may defer broadcasting until after the client
/// reveals the preimage; client MUST send the preimage once HTLC(s) are
/// irrevocably committed.
#[serde(default)]
pub client_trusts_lsp: bool,
}
Expand Down
Loading
Loading