Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ interface Node {
OnchainPayment onchain_payment();
UnifiedPayment unified_payment();
Liquidity liquidity();
LSPS5Liquidity lsps5_liquidity();
[Throws=NodeError]
void lnurl_auth(string lnurl);
[Throws=NodeError]
Expand Down Expand Up @@ -169,6 +170,8 @@ typedef interface UnifiedPayment;

typedef interface Liquidity;

typedef interface LSPS5Liquidity;

[Error]
enum NodeError {
"AlreadyRunning",
Expand Down Expand Up @@ -231,6 +234,9 @@ enum NodeError {
"LnurlAuthFailed",
"LnurlAuthTimeout",
"InvalidLnurl",
"LiquiditySetWebhookFailed",
"LiquidityRemoveWebhookFailed",
"LiquidityListWebhooksFailed"
};

typedef dictionary NodeStatus;
Expand Down
39 changes: 36 additions & 3 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ use crate::runtime::{Runtime, RuntimeSpawner};
use crate::tx_broadcaster::TransactionBroadcaster;
use crate::types::{
AsyncPersister, ChainMonitor, ChannelManager, DynStore, DynStoreRef, DynStoreWrapper,
GossipSync, Graph, HRNResolver, KeysManager, MessageRouter, OnionMessenger, PaymentStore,
PeerManager, PendingPaymentStore,
GossipSync, Graph, HRNResolver, KeysManager, LSPS5ServiceConfig, MessageRouter, OnionMessenger,
PaymentStore, PeerManager, PendingPaymentStore,
};
use crate::wallet::persist::KVStoreWalletPersister;
use crate::wallet::Wallet;
Expand Down Expand Up @@ -122,10 +122,12 @@ struct PathfindingScoresSyncConfig {

#[derive(Debug, Clone, Default)]
struct LiquiditySourceConfig {
// Acts for both LSPS1 and LSPS2 clients connecting to the given service.
// Acts for LSPS1, LSPS2 and LSPS5 clients connecting to the given service.
lsp_nodes: Vec<LspConfig>,
// Act as an LSPS2 service.
lsps2_service: Option<LSPS2ServiceConfig>,
// Act as an LSPS5 service.
lsps5_service: Option<LSPS5ServiceConfig>,
}

#[derive(Clone)]
Expand Down Expand Up @@ -514,6 +516,21 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to provide an [bLIP-55 / LSPS5] service, enabling clients
/// to register webhooks for push notifications.
///
/// **Caution**: LSP service support is in **alpha** and is considered an experimental feature.
///
/// [bLIP-55 / LSPS5]: https://github.com/lightning/blips/blob/master/blip-0055.md
pub fn enable_liquidity_provider_lsps5(
&mut self, lsps5_service_config: LSPS5ServiceConfig,
) -> &mut Self {
let liquidity_source_config =
self.liquidity_source_config.get_or_insert(LiquiditySourceConfig::default());
liquidity_source_config.lsps5_service = Some(lsps5_service_config);
self
}

/// Sets the used storage directory path.
pub fn set_storage_dir_path(&mut self, storage_dir_path: String) -> &mut Self {
self.config.storage_dir_path = storage_dir_path;
Expand Down Expand Up @@ -1081,6 +1098,16 @@ impl ArcedNodeBuilder {
self.inner.write().expect("lock").enable_liquidity_provider(lsps2_service_config);
}

/// Configures the [`Node`] instance to provide an [bLIP-55 / LSPS5] service, enabling clients
/// to register webhooks for push notifications.
///
/// **Caution**: LSP service support is in **alpha** and is considered an experimental feature.
///
/// [bLIP-55 / LSPS5]: https://github.com/lightning/blips/blob/master/blip-0055.md
pub fn enable_liquidity_provider_lsps5(&self, lsps5_service_config: LSPS5ServiceConfig) {
self.inner.write().expect("lock").enable_liquidity_provider_lsps5(lsps5_service_config);
}

/// Sets the used storage directory path.
pub fn set_storage_dir_path(&self, storage_dir_path: String) {
self.inner.write().expect("lock").set_storage_dir_path(storage_dir_path);
Expand Down Expand Up @@ -2081,6 +2108,10 @@ fn build_with_store_internal(
lsc.lsps2_service.as_ref().map(|config| {
liquidity_source_builder.lsps2_service(promise_secret, config.clone())
});

lsc.lsps5_service
.as_ref()
.map(|config| liquidity_source_builder.lsps5_service(config.clone()));
}

let liquidity_source = runtime
Expand Down Expand Up @@ -2140,6 +2171,8 @@ fn build_with_store_internal(

liquidity_source.lsps2_service().set_peer_manager(Arc::downgrade(&peer_manager));

liquidity_source.lsps5_service().set_peer_manager(Arc::downgrade(&peer_manager));

let connection_manager = Arc::new(ConnectionManager::new(
Arc::clone(&peer_manager),
config.tor_config.clone(),
Expand Down
15 changes: 15 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ pub enum Error {
LnurlAuthTimeout,
/// The provided lnurl is invalid.
InvalidLnurl,
/// Failed to set a webhook with the LSP.
LiquiditySetWebhookFailed,
/// Failed to remove a webhook with the LSP.
LiquidityRemoveWebhookFailed,
/// Failed to list webhooks with the LSP.
LiquidityListWebhooksFailed,
}

impl fmt::Display for Error {
Expand Down Expand Up @@ -222,6 +228,15 @@ impl fmt::Display for Error {
Self::LnurlAuthFailed => write!(f, "LNURL-auth authentication failed."),
Self::LnurlAuthTimeout => write!(f, "LNURL-auth authentication timed out."),
Self::InvalidLnurl => write!(f, "The provided lnurl is invalid."),
Self::LiquiditySetWebhookFailed => {
write!(f, "Failed to set a webhook with the LSP.")
},
Self::LiquidityRemoveWebhookFailed => {
write!(f, "Failed to remove a webhook with the LSP.")
},
Self::LiquidityListWebhooksFailed => {
write!(f, "Failed to list webhooks with the LSP.")
},
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,8 @@ where
"Onion message intercepted, but no onion message mailbox available"
);
}

self.liquidity_source.lsps5_service().notify_onion_message_incoming(peer_node_id);
},
LdkEvent::OnionMessagePeerConnected { peer_node_id } => {
if let Some(om_mailbox) = self.om_mailbox.as_ref() {
Expand Down
Loading