-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat(lsp): Add support for lsp
in lampo
#277
base: main
Are you sure you want to change the base?
Conversation
This commit allows to create JIT(Just in time) channels for our node. https://github.com/BitcoinAndLightningLayerSpecs/lsp/tree/main/LSPS2
This commit allows our node to act as a server to provide liquidity to other nodes.
// Must be used when we act as a liquidity provider | ||
conf.ldk_conf = UserConfig { | ||
accept_intercept_htlcs: true, | ||
..Default::default() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this is the correct place
lampo-common/src/conf.rs
Outdated
// These functions should be called when we get something like | ||
// liquidity=consumer of liquidity=provider inside lampo.conf | ||
pub fn configure_as_liquidity_consumer(&mut self) { | ||
self.liquidity = Some("Consumer".to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.liquidity = Some("Consumer".to_string()) | |
self.liquidity = Some("Consumer".to_string()) |
use an enum like LiquisityProvider::Consumer
use lightning_liquidity::{lsps0::ser::RequestId, lsps2::msgs::OpeningFeeParams}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum LiquidityEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure that this is the correct place where to put the event, but maybe this can be moved later in another crate
@@ -48,3 +48,7 @@ pub mod btc_rpc { | |||
pub mempoolminfee: f32, | |||
} | |||
} | |||
|
|||
pub mod chrono { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not understand why we need this
@@ -44,27 +46,33 @@ pub type SimpleArcPeerManager<M, T, L> = PeerManager< | |||
Arc<P2PGossipSync<Arc<NetworkGraph<Arc<L>>>, Arc<T>, Arc<L>>>, | |||
Arc<LampoArcOnionMessenger<L>>, | |||
Arc<L>, | |||
IgnoringMessageHandler, | |||
LampoCustomMessageHandler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LampoCustomMessageHandler, | |
LampoMessageHandler, |
Renaming
Arc<LampoKeysManager>, | ||
>; | ||
|
||
type InnerLampoPeerManager = | ||
pub type InnerLampoPeerManager = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
node3.fund_wallet(6).unwrap(); | ||
Err(()) | ||
}); | ||
// This would return a timeout as json_pay will continue to wait till it get an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the code where you are calling accept_inbound_channel_from_trusted_peer_0conf
?
lampod/src/actions/handler.rs
Outdated
if let Some(_) = liquidity_manager { | ||
let _ = self.channel_manager.channeld().accept_inbound_channel_from_trusted_peer_0conf(&temporary_channel_id, &counterparty_node_id, 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this is called at any point. We should keep the error here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is being called when we specifically accepting the channels with 0conf
, which would be used when we are a client requesting for in bound liquidity. This would come handy when the payer pays the JIT invoice and the LSP on the go creates a channel with the client.
lampod/src/actions/handler.rs
Outdated
} | ||
ldk::events::Event::ChannelReady { | ||
channel_id, | ||
user_channel_id, | ||
counterparty_node_id, | ||
channel_type, | ||
} => { | ||
let liquidity_manager = self.liquidity_manager.clone(); | ||
if let Some(ref liq_manager) = liquidity_manager { | ||
let _ = liquidity_manager.unwrap().channel_ready(user_channel_id, &channel_id, &counterparty_node_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should do this only with the LSP not with any nodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we are doing this when we have some liquidity config inside the lampo.conf
This project aims to configure lampo to be able to act as a lightning liquidity provider and be able to act both as a client and as a server.
Changes done:
lampo-common/src/conf.rs
: Configure lampo config to be able to act as provider or client based on the input we give.lampo-common/src/event/liquidity.rs
: Created a new event file where we handle all the incoming events from thelightning-liquidity
lampod/src/actions/handler.rs
: Made changes to emit different events while we act as a server, events could be:HTLCIntercepted
,PaymentForwarded
,HTLCHandlingFailed
etc.lampod/src/lib.rs
: Made suitable changes to spin up our node with different configs formessage_handler
.lampod/src/ln/message_handler.rs
: This was mostly copied from the https://github.com/tnull/ldk-node-hack as it serves two different handlers for peer manager, when we are not acting as a LSP we handle the messages viaLampoCustomMessageHandler::Liquidity
andLampoCustomMessageHandler::Ignoring
is basically a dummy handler.tests/tests/src/lampo_tests.rs
: Created two new tests for the LSPs.