ln/tests: return BlindedPaymentPath from trampoline helper
What changed, and why it matters
This commit is a test-only refactor. It changes a helper function used in Lightning Dev Kit's internal tests so that it returns both a blinded payment tail and the full blinded payment path. This lets tests register the path in payment parameters, matching a recent requirement in the codebase. There is no change to production code, user-facing behavior, or security-sensitive logic.
No security action needed. This is a routine test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies create_trampoline_forward_blinded_tail in functional_test_utils.rs to return a tuple (BlindedTail, BlindedPaymentPath) instead of only BlindedTail. It updates one test, do_test_trampoline_relay, to use the returned BlindedPaymentPath when constructing PaymentParameters for blinded trampoline payment tests. The change is purely internal to the test suite and aligns test setup with the now-required PaymentParameters API.
Changed components
lightning/src/ln/blinded_payment_tests.rslightning/src/ln/functional_test_utils.rsInspect captured patch +43 / −30
diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs
index e4538e4..c67c593 100644
--- a/lightning/src/ln/blinded_payment_tests.rs
+++ b/lightning/src/ln/blinded_payment_tests.rs
@@ -2580,6 +2580,39 @@ fn do_test_trampoline_relay(blinded: bool, test_case: TrampolineTestCase) {
let override_random_bytes = [42; 32];
*nodes[0].keys_manager.override_random_bytes.lock().unwrap() = Some(override_random_bytes);
+ // Create a blinded tail where Carol is receiving. In our unblinded test cases, we'll
+ // override this anyway (with a tail sending to an unblinded receive, which LDK doesn't
+ // allow).
+ let (blinded_tail, blinded_path) = create_trampoline_forward_blinded_tail(
+ &secp_ctx,
+ &nodes[2].keys_manager,
+ &[],
+ carol_node_id,
+ nodes[2].keys_manager.get_receive_auth_key(),
+ ReceiveTlvs {
+ payment_secret,
+ payment_constraints: PaymentConstraints {
+ max_cltv_expiry: u32::max_value(),
+ htlc_minimum_msat: original_amt_msat,
+ },
+ payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {
+ payment_metadata: None,
+ }),
+ },
+ original_trampoline_cltv,
+ excess_final_cltv,
+ original_amt_msat,
+ );
+
+ // When Carol receives over the blinded path, register it in the payment parameters as we
+ // would for a real blinded payment. In the unblinded test cases the blinded tail is overridden,
+ // so the payee is just Carol's unblinded node id.
+ let payment_params = if blinded {
+ PaymentParameters::blinded(vec![blinded_path])
+ } else {
+ PaymentParameters::from_node_id(carol_node_id, original_trampoline_cltv + excess_final_cltv)
+ };
+
let route = Route {
paths: vec![Path {
hops: vec![
@@ -2602,35 +2635,10 @@ fn do_test_trampoline_relay(blinded: bool, test_case: TrampolineTestCase) {
maybe_announced_channel: false,
},
],
- // Create a blinded tail where Carol is receiving. In our unblinded test cases, we'll
- // override this anyway (with a tail sending to an unblinded receive, which LDK doesn't
- // allow).
- blinded_tail: Some(create_trampoline_forward_blinded_tail(
- &secp_ctx,
- &nodes[2].keys_manager,
- &[],
- carol_node_id,
- nodes[2].keys_manager.get_receive_auth_key(),
- ReceiveTlvs {
- payment_secret,
- payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
- htlc_minimum_msat: original_amt_msat,
- },
- payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {
- payment_metadata: None,
- }),
- },
- original_trampoline_cltv,
- excess_final_cltv,
- original_amt_msat,
- )),
+ blinded_tail: Some(blinded_tail),
}],
route_params: RouteParameters::from_payment_params_and_value(
- PaymentParameters::from_node_id(
- carol_node_id,
- original_trampoline_cltv + excess_final_cltv,
- ),
+ payment_params,
original_amt_msat,
),
};
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 6e855c2..475764e 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -5780,12 +5780,16 @@ pub fn get_scid_from_channel_id<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, channel_id:
///
/// The resulting tail contains blinded hops built from `intermediate_nodes` plus a dummy receive
/// TLV, with the `TrampolineHop` fee and CLTV derived from the blinded path's aggregated payinfo.
+/// The constructed [`BlindedPaymentPath`] is also returned so callers can register it in
+/// [`PaymentParameters`].
+///
+/// [`PaymentParameters`]: crate::routing::router::PaymentParameters
pub fn create_trampoline_forward_blinded_tail<ES: EntropySource>(
secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>, entropy_source: ES,
intermediate_nodes: &[ForwardNode<TrampolineForwardTlvs>], payee_node_id: PublicKey,
payee_receive_key: ReceiveAuthKey, payee_tlvs: ReceiveTlvs, min_final_cltv_expiry_delta: u32,
excess_final_cltv_delta: u32, final_value_msat: u64,
-) -> BlindedTail {
+) -> (BlindedTail, BlindedPaymentPath) {
let blinded_path = BlindedPaymentPath::new_for_trampoline(
intermediate_nodes,
payee_node_id,
@@ -5798,7 +5802,7 @@ pub fn create_trampoline_forward_blinded_tail<ES: EntropySource>(
)
.unwrap();
- BlindedTail {
+ let tail = BlindedTail {
trampoline_hops: vec![TrampolineHop {
pubkey: intermediate_nodes.first().map(|n| n.node_id).unwrap_or(payee_node_id),
node_features: types::features::Features::empty(),
@@ -5817,5 +5821,6 @@ pub fn create_trampoline_forward_blinded_tail<ES: EntropySource>(
blinding_point: blinded_path.blinding_point(),
excess_final_cltv_expiry_delta: excess_final_cltv_delta,
final_value_msat,
- }
+ };
+ (tail, blinded_path)
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.