Skip to content

Commit 095ba89

Browse files
authored
Merge pull request #503 from tnull/2025-03-set-priv-channel-forward-if-lsp
Allow forwarding to unannounced channels if LSP service is enabled
2 parents 7528e91 + da5a839 commit 095ba89

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,14 @@ fn build_with_store_internal(
11591159
// If we act as an LSPS2 service, we need to to be able to intercept HTLCs and forward the
11601160
// information to the service handler.
11611161
user_config.accept_intercept_htlcs = true;
1162+
1163+
// If we act as an LSPS2 service, we allow forwarding to unnannounced channels.
1164+
user_config.accept_forwards_to_priv_channels = true;
1165+
1166+
// If we act as an LSPS2 service, set the HTLC-value-in-flight to 100% of the channel value
1167+
// to ensure we can forward the initial payment.
1168+
user_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1169+
100;
11621170
}
11631171

11641172
let message_router =

src/liquidity.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,14 @@ where
675675

676676
let mut config = *self.channel_manager.get_current_default_configuration();
677677

678-
// Set the HTLC-value-in-flight to 100% of the channel value to ensure we can
679-
// forward the payment.
680-
config
681-
.channel_handshake_config
682-
.max_inbound_htlc_value_in_flight_percent_of_channel = 100;
678+
// We set these LSP-specific values during Node building, here we're making sure it's actually set.
679+
debug_assert_eq!(
680+
config
681+
.channel_handshake_config
682+
.max_inbound_htlc_value_in_flight_percent_of_channel,
683+
100
684+
);
685+
debug_assert!(config.accept_forwards_to_priv_channels);
683686

684687
// We set the forwarding fee to 0 for now as we're getting paid by the channel fee.
685688
//

tests/integration_tests_rust.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,22 @@ fn lsps2_client_service_integration() {
12401240
(expected_received_amount_msat + expected_channel_overprovisioning_msat) / 1000;
12411241
let channel_value_sats = client_node.list_channels().first().unwrap().channel_value_sats;
12421242
assert_eq!(channel_value_sats, expected_channel_size_sat);
1243+
1244+
println!("Generating regular invoice!");
1245+
let invoice_description =
1246+
Bolt11InvoiceDescription::Direct(Description::new(String::from("asdf")).unwrap());
1247+
let amount_msat = 5_000_000;
1248+
let invoice = client_node
1249+
.bolt11_payment()
1250+
.receive(amount_msat, &invoice_description.into(), 1024)
1251+
.unwrap();
1252+
1253+
// Have the payer_node pay the invoice, to check regular forwards service_node -> client_node
1254+
// are working as expected.
1255+
println!("Paying regular invoice!");
1256+
let payment_id = payer_node.bolt11_payment().send(&invoice, None).unwrap();
1257+
expect_payment_successful_event!(payer_node, Some(payment_id), None);
1258+
expect_payment_received_event!(client_node, amount_msat);
12431259
}
12441260

12451261
#[test]

0 commit comments

Comments
 (0)