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
48 changes: 24 additions & 24 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 = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["std"] }
lightning-types = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245" }
lightning-invoice = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["std"] }
lightning-net-tokio = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245" }
lightning-persister = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["tokio"] }
lightning-background-processor = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245" }
lightning-rapid-gossip-sync = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245" }
lightning-block-sync = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["std"] }
lightning-macros = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245" }
lightning = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", features = ["std"] }
lightning-types = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-invoice = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", features = ["std"] }
lightning-net-tokio = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-persister = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", features = ["tokio"] }
lightning-background-processor = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-rapid-gossip-sync = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-block-sync = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", features = ["std"] }
lightning-macros = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }

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 Down Expand Up @@ -85,7 +85,7 @@ bitcoin-payment-instructions = { git = "http://github.com/jkczyz/bitcoin-paymen
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "http://github.com/lightningdevkit/rust-lightning", rev = "98501d6e5134228c41460dcf786ab53337e41245", features = ["std", "_test_utils"] }
lightning = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a", 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 @@ -171,15 +171,15 @@ harness = false
#vss-client-ng = { path = "../vss-client" }
#vss-client-ng = { git = "http://github.com/lightningdevkit/vss-client", branch = "main" }
#
#[patch."http://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."http://github.com/lightningdevkit/rust-lightning"]
lightning = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-types = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-invoice = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-net-tokio = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-persister = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-background-processor = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-rapid-gossip-sync = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-block-sync = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-transaction-sync = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-liquidity = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
lightning-macros = { git = "http://github.com/tnull/rust-lightning", rev = "2cb054601134943d5c8e5a39d014e7b125c7a19a" }
106 changes: 58 additions & 48 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use lightning::util::persist::{
};
use lightning::util::ser::ReadableArgs;
use lightning::util::sweep::OutputSweeper;
use lightning_liquidity::lsps2::router::LSPS2BOLT12Router;
use lightning_persister::fs_store::v1::FilesystemStore;
use vss_client::headers::VssHeaderProvider;

Expand Down Expand Up @@ -1518,13 +1519,14 @@ 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 router = Arc::new(LSPS2BOLT12Router::new(inner_router, Arc::clone(&keys_manager)));

let mut user_config = default_user_config(&config);

Expand Down Expand Up @@ -1681,56 +1683,64 @@ fn build_with_store_internal(
},
};

let (liquidity_source, custom_message_handler) =
if let Some(lsc) = liquidity_source_config.as_ref() {
let mut liquidity_source_builder = LiquiditySourceBuilder::new(
Arc::clone(&wallet),
Arc::clone(&channel_manager),
Arc::clone(&keys_manager),
Arc::clone(&chain_source),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
);
let (liquidity_source, custom_message_handler) = if let Some(lsc) =
liquidity_source_config.as_ref()
{
let mut liquidity_source_builder = LiquiditySourceBuilder::new(
Arc::clone(&wallet),
Arc::clone(&channel_manager),
Arc::clone(&keys_manager),
Arc::clone(&router),
Arc::clone(&chain_source),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Some(Arc::clone(&onion_messenger)
as Arc<
dyn lightning::onion_message::messenger::OnionMessageInterceptor + Send + Sync,
>),
Arc::clone(&logger),
);

lsc.lsps1_client.as_ref().map(|config| {
liquidity_source_builder.lsps1_client(
config.node_id,
config.address.clone(),
config.token.clone(),
)
});
lsc.lsps1_client.as_ref().map(|config| {
liquidity_source_builder.lsps1_client(
config.node_id,
config.address.clone(),
config.token.clone(),
)
});

lsc.lsps2_client.as_ref().map(|config| {
liquidity_source_builder.lsps2_client(
config.node_id,
config.address.clone(),
config.token.clone(),
)
});
lsc.lsps2_client.as_ref().map(|config| {
liquidity_source_builder.lsps2_client(
config.node_id,
config.address.clone(),
config.token.clone(),
)
});

let promise_secret = {
let lsps_xpriv = derive_xprv(
Arc::clone(&config),
&seed_bytes,
LSPS_HARDENED_CHILD_INDEX,
Arc::clone(&logger),
)?;
lsps_xpriv.private_key.secret_bytes()
};
lsc.lsps2_service.as_ref().map(|config| {
liquidity_source_builder.lsps2_service(promise_secret, config.clone())
});

let liquidity_source = runtime
.block_on(async move { liquidity_source_builder.build().await.map(Arc::new) })?;
let custom_message_handler =
Arc::new(NodeCustomMessageHandler::new_liquidity(Arc::clone(&liquidity_source)));
(Some(liquidity_source), custom_message_handler)
} else {
(None, Arc::new(NodeCustomMessageHandler::new_ignoring()))
let promise_secret = {
let lsps_xpriv = derive_xprv(
Arc::clone(&config),
&seed_bytes,
LSPS_HARDENED_CHILD_INDEX,
Arc::clone(&logger),
)?;
lsps_xpriv.private_key.secret_bytes()
};
lsc.lsps2_service
.as_ref()
.map(|config| liquidity_source_builder.lsps2_service(promise_secret, config.clone()));

let liquidity_source = runtime
.block_on(async move { liquidity_source_builder.build().await.map(Arc::new) })?;
// TODO: Rehydrate persisted `OfferId -> LSPS2Bolt12InvoiceParameters` mappings here for
// client nodes and call `router.register_offer(...)` before startup completes.
let custom_message_handler =
Arc::new(NodeCustomMessageHandler::new_liquidity(Arc::clone(&liquidity_source)));
(Some(liquidity_source), custom_message_handler)
} else {
(None, Arc::new(NodeCustomMessageHandler::new_ignoring()))
};

let msg_handler = match gossip_source.as_gossip_sync() {
GossipSync::P2P(p2p_gossip_sync) => MessageHandler {
Expand Down
22 changes: 20 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,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 @@ -913,9 +917,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 Expand Up @@ -1463,7 +1471,12 @@ impl Node {

let funding_template = self
.channel_manager
.splice_channel(&channel_details.channel_id, &counterparty_node_id, fee_rate)
.splice_channel(
&channel_details.channel_id,
&counterparty_node_id,
fee_rate,
fee_rate,
)
.map_err(|e| {
log_error!(self.logger, "Failed to splice channel: {:?}", e);
Error::ChannelSplicingFailed
Expand Down Expand Up @@ -1572,7 +1585,12 @@ impl Node {

let funding_template = self
.channel_manager
.splice_channel(&channel_details.channel_id, &counterparty_node_id, fee_rate)
.splice_channel(
&channel_details.channel_id,
&counterparty_node_id,
fee_rate,
fee_rate,
)
.map_err(|e| {
log_error!(self.logger, "Failed to splice channel: {:?}", e);
Error::ChannelSplicingFailed
Expand Down
Loading
Loading