Skip to content
Draft
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
52 changes: 26 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ default = []
#lightning-liquidity = { version = "0.2.0", features = ["std"] }
#lightning-macros = { version = "0.2.0" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
lightning = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["std"] }
lightning-types = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-invoice = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-persister = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-rapid-gossip-sync = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-block-sync = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["std"] }
lightning-macros = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }

bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
Expand All @@ -66,7 +66,7 @@ bip21 = { version = "0.5", features = ["std"], default-features = false }
base64 = { version = "0.22.1", default-features = false, features = ["std"] }
getrandom = { version = "0.3", default-features = false }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros", "net" ] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.12", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.24.0", default-features = false, features = ["proxy", "use-rustls-ring"] }
libc = "0.2"
Expand All @@ -79,13 +79,13 @@ async-trait = { version = "0.1", default-features = false }
vss-client = { package = "vss-client-ng", version = "0.5" }
prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.6" }
bitcoin-payment-instructions = { git = "https://github.com/joostjager/bitcoin-payment-instructions", branch = "ldk-dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
bitcoin-payment-instructions = { git = "https://github.com/jkczyz/bitcoin-payment-instructions", rev = "0138feb7acefb1e49102a6fb46d7b776bf43265e" }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std", "_test_utils"] }
lightning = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0", features = ["std", "_test_utils"] }
rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down Expand Up @@ -172,15 +172,15 @@ harness = false
#vss-client-ng = { path = "../vss-client" }
#vss-client-ng = { git = "https://github.com/lightningdevkit/vss-client", branch = "main" }
#
#[patch."https://github.com/lightningdevkit/rust-lightning"]
#lightning = { path = "../rust-lightning/lightning" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync" }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity" }
#lightning-macros = { path = "../rust-lightning/lightning-macros" }
[patch."https://github.com/lightningdevkit/rust-lightning"]
lightning = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-types = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-invoice = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-net-tokio = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-persister = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-background-processor = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-rapid-gossip-sync = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-block-sync = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-transaction-sync = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-liquidity = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
lightning-macros = { git = "https://github.com/tnull/rust-lightning", rev = "71242155f2b90007e850be89daef4db78d8508f0" }
18 changes: 14 additions & 4 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
use lightning::log_trace;
use lightning::routing::gossip::NodeAlias;
use lightning::routing::router::DefaultRouter;
use lightning_liquidity::lsps2::router::LSPS2BOLT12Router;
use lightning::routing::scoring::{
CombinedScorer, ProbabilisticScorer, ProbabilisticScoringDecayParameters,
ProbabilisticScoringFeeParameters,
Expand Down Expand Up @@ -77,7 +78,7 @@ use crate::runtime::{Runtime, RuntimeSpawner};
use crate::tx_broadcaster::TransactionBroadcaster;
use crate::types::{
AsyncPersister, ChainMonitor, ChannelManager, DynStore, DynStoreRef, DynStoreWrapper,
GossipSync, Graph, KeysManager, MessageRouter, OnionMessenger, PaymentStore, PeerManager,
GossipSync, Graph, InnerMessageRouter, KeysManager, OnionMessenger, PaymentStore, PeerManager,
PendingPaymentStore, SyncAndAsyncKVStore,
};
use crate::wallet::persist::KVStoreWalletPersister;
Expand Down Expand Up @@ -1622,12 +1623,19 @@ fn build_with_store_internal(
}

let scoring_fee_params = ProbabilisticScoringFeeParameters::default();
let router = Arc::new(DefaultRouter::new(
let inner_router = DefaultRouter::new(
Arc::clone(&network_graph),
Arc::clone(&logger),
Arc::clone(&keys_manager),
Arc::clone(&scorer),
scoring_fee_params,
);
let inner_message_router =
InnerMessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));
let router = Arc::new(LSPS2BOLT12Router::new(
inner_router,
inner_message_router,
Arc::clone(&keys_manager),
));

let mut user_config = default_user_config(&config);
Expand Down Expand Up @@ -1656,8 +1664,7 @@ fn build_with_store_internal(
}
}

let message_router =
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));
let message_router = Arc::clone(&router);

// Initialize the ChannelManager
let channel_manager = {
Expand Down Expand Up @@ -1791,6 +1798,7 @@ fn build_with_store_internal(
Arc::clone(&wallet),
Arc::clone(&channel_manager),
Arc::clone(&keys_manager),
Arc::clone(&router),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Expand Down Expand Up @@ -1828,6 +1836,8 @@ fn build_with_store_internal(

let liquidity_source = runtime
.block_on(async move { liquidity_source_builder.build().await.map(Arc::new) })?;
// TODO: Rehydrate persisted intercept SCID -> LSPS2Bolt12InvoiceParameters mappings here
// for client nodes and call `router.register_intercept_scid(...)` before startup completes.
let custom_message_handler =
Arc::new(NodeCustomMessageHandler::new_liquidity(Arc::clone(&liquidity_source)));
(Some(liquidity_source), custom_message_handler)
Expand Down
33 changes: 25 additions & 8 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,12 @@ where
claim_from_onchain_tx,
outbound_amount_forwarded_msat,
} => {
let prev_channel_id = prev_htlcs.first().map(|h| h.channel_id);
let next_channel_id = next_htlcs.first().map(|h| h.channel_id);
let prev_user_channel_id = prev_htlcs.first().and_then(|h| h.user_channel_id);
let next_user_channel_id = next_htlcs.first().and_then(|h| h.user_channel_id);
let prev_node_id = prev_htlcs.first().and_then(|h| h.node_id);
let next_node_id = next_htlcs.first().and_then(|h| h.node_id);
{
let read_only_network_graph = self.network_graph.read_only();
let nodes = read_only_network_graph.nodes();
Expand Down Expand Up @@ -1653,14 +1659,25 @@ where

self.bump_tx_event_handler.handle_event(&bte).await;
},
LdkEvent::OnionMessageIntercepted { peer_node_id, message } => {
if let Some(om_mailbox) = self.om_mailbox.as_ref() {
om_mailbox.onion_message_intercepted(peer_node_id, message);
} else {
log_trace!(
self.logger,
"Onion message intercepted, but no onion message mailbox available"
);
LdkEvent::OnionMessageIntercepted { next_hop, message } => {
match next_hop {
lightning::blinded_path::message::NextMessageHop::NodeId(peer_node_id) => {
if let Some(om_mailbox) = self.om_mailbox.as_ref() {
om_mailbox.onion_message_intercepted(peer_node_id, message);
} else {
log_trace!(
self.logger,
"Onion message intercepted, but no onion message mailbox available"
);
}
},
lightning::blinded_path::message::NextMessageHop::ShortChannelId(scid) => {
log_trace!(
self.logger,
"Onion message intercepted for unknown SCID {}, ignoring",
scid
);
},
}
},
LdkEvent::OnionMessagePeerConnected { peer_node_id } => {
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,13 @@ impl Node {
#[cfg(not(feature = "uniffi"))]
pub fn bolt12_payment(&self) -> Bolt12Payment {
Bolt12Payment::new(
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
self.liquidity_source.clone(),
Arc::clone(&self.keys_manager),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Arc::clone(&self.config),
Arc::clone(&self.is_running),
Arc::clone(&self.logger),
Expand All @@ -917,9 +921,13 @@ impl Node {
#[cfg(feature = "uniffi")]
pub fn bolt12_payment(&self) -> Arc<Bolt12Payment> {
Arc::new(Bolt12Payment::new(
Arc::clone(&self.runtime),
Arc::clone(&self.channel_manager),
Arc::clone(&self.connection_manager),
self.liquidity_source.clone(),
Arc::clone(&self.keys_manager),
Arc::clone(&self.payment_store),
Arc::clone(&self.peer_store),
Arc::clone(&self.config),
Arc::clone(&self.is_running),
Arc::clone(&self.logger),
Expand Down
Loading
Loading