Skip to content

Conversation

shaavan
Copy link
Owner

@shaavan shaavan commented Oct 3, 2025

Summary by CodeRabbit

  • New Features

    • Blinded payments now include a receive-auth key; inbound payloads report whether payment TLVs were authenticated. Entropy no longer required in several offer/invoice flows.
  • Bug Fixes

    • Unauthenticated inbound payments are rejected earlier with a new failure reason. Startup/deserialization now tolerates older serialized states for safer upgrades.
  • Tests

    • Test suites updated for the authenticated receive flow, new failure paths, and revised blinded-path construction.

Copy link

coderabbitai bot commented Oct 3, 2025

Walkthrough

Threads a ReceiveAuthKey through blinded-payment path construction and decryption, replaces UnauthenticatedReceiveTlvs with ReceiveTlvs, adds payment_tlvs_authenticated to inbound payloads, enforces TLV authentication in HTLC processing, removes nonce/HMAC helpers, updates Router/offers APIs, tests, fuzzers, and ChannelManager deserialization compatibility.

Changes

Cohort / File(s) Summary of Changes
Router API & test glue
lightning/src/routing/router.rs, lightning/src/util/test_utils.rs, fuzz/src/full_stack.rs, fuzz/src/chanmon_consistency.rs
create_blinded_payment_paths signature now accepts receive_auth_key: ReceiveAuthKey as the second argument; trait impls, test helpers and fuzzer routers updated; call sites and imports adjusted; TLV access updated (e.g., tlvs.payment_constraints).
Blinded payment path & TLVs core
lightning/src/blinded_path/payment.rs
Removed UnauthenticatedReceiveTlvs; introduced public ReceiveTlvs fields; BlindedPaymentPath::new/one_hop/blinded_hops/compute_payinfo now accept and thread receive_auth_key; decryption switched to ChaChaDualPolyReadAdapter using receive auth.
Offers flow & signer
lightning/src/offers/flow.rs, lightning/src/offers/signer.rs
Offers APIs removed entropy_source generics/params; TLV construction now uses ReceiveTlvs and ReceiveAuthKey; HMAC/nonce-based helper functions and PAYMENT_TLVS_HMAC_INPUT removed/commented.
Inbound onion decode & payloads
lightning/src/ln/msgs.rs
Replaced ChaChaPolyReadAdapter with ChaChaDualPolyReadAdapter and pass receive_auth_key; added payment_tlvs_authenticated: bool to inbound payload structs; propagate used_aad into validation and payloads.
Failure reasons & utils
lightning/src/ln/onion_utils.rs
Added UnauthenticatedPayload variant to LocalHTLCFailureReason; updated mapping, serialization/deserialization, and debug validation handling.
Inbound HTLC processing
lightning/src/ln/onion_payment.rs
create_recv_pending_htlc_info gains a generic logger parameter and enforces payment_tlvs_authenticated (rejects unauthenticated payloads with the new failure variant); call sites updated to pass logger.deref().
Tests & async payments
lightning/src/ln/blinded_payment_tests.rs, lightning/src/ln/max_payment_path_len_tests.rs, lightning/src/ln/async_payments_tests.rs
Tests migrated from UnauthenticatedReceiveTlvs to ReceiveTlvs; removed nonce/auth flows in favor of ReceiveAuthKey; updated BlindedPaymentPath calls and removed entropy_source usage where applicable.
Fuzzers: TLVs & keys
fuzz/src/invoice_request_deser.rs, fuzz/src/refund_deser.rs, fuzz/src/chanmon_consistency.rs
Fuzz inputs updated to use ReceiveTlvs and local ReceiveAuthKey; nonce/ExpandedKey code removed; BlindedPaymentPath::new invocations updated and TLV field accesses adjusted; APIError import removed in one fuzzer.
Offers API surface
lightning/src/offers/flow.rs (expanded)
Multiple public offers APIs had entropy_source/ES bounds removed; create_blinded_payment_paths and related helpers now require receive_auth_key wiring instead of per-call entropy.
ChannelManager deserialization
lightning/src/ln/channelmanager.rs
Large internal deserialization refactor adding extensive legacy-format handling, migration logic, version checks and map rebuilds; no public signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Router
  participant BPP as BlindedPaymentPath
  participant Hops as blinded_hops

  Caller->>Router: create_blinded_payment_paths(recipient, receive_auth_key, first_hops, tlvs, amount, secp)
  Router->>BPP: BlindedPaymentPath::new(intermediate_nodes, payee_id, receive_auth_key, payee_tlvs, limits, cltv, secp)
  BPP->>Hops: blinded_hops(..., payee_tlvs, session_priv, receive_auth_key)
  Hops-->>BPP: hops
  BPP-->>Router: Vec<BlindedPaymentPath>
  Router-->>Caller: Result<Vec<...>, ()>
  note right of Router: ReceiveAuthKey is threaded into construction and decryption
Loading
sequenceDiagram
  autonumber
  actor Peer
  participant Node
  participant Decoder as OnionDecoder
  participant Proc as create_recv_pending_htlc_info

  Peer->>Node: update_add_htlc(onion)
  Node->>Decoder: decode_incoming_update_add_htlc_onion(..., receive_auth_key)
  Decoder-->>Node: hop_data { payment_tlvs_authenticated }
  Node->>Proc: create_recv_pending_htlc_info(..., hop_data, logger)
  alt payment_tlvs_authenticated == true
    Proc-->>Node: PendingHTLCInfo (accept)
  else
    Proc-->>Node: Err(UnauthenticatedPayload) (reject)
  end
  note right of Proc: Authentication enforced before further validation
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

A rabbit with keys in a moonlit stack,
Threads auth through hops — no nonce to track.
Blinded paths hum with a keyed hello,
Bad onions bounce, good payments go.
I twitch my whiskers and guard the flow. 🐇🔑

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The provided title includes an unnecessary “Review Branch:” prefix and mixes metadata with the core change, which detracts from clarity and conciseness. While it references ReceiveAuthKey verification, it does not succinctly convey the primary update to method signatures and authentication flow in blinded payment paths. According to the title guidelines, it should be a brief, single sentence that directly summarizes the main change without extraneous information. Rename the pull request to focus solely on the substantive change, for example “Integrate ReceiveAuthKey authentication into blinded payment path flow,” removing the “Review Branch:” prefix and capturing the core update in a clear, concise manner.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch aad-payment-review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lightning/src/offers/flow.rs (1)

812-867: Update remaining call sites to include the router argument
• lightning/src/ln/async_payments_tests.rs:331, 698, 1678 – pass &router (e.g., &recipient.router or appropriate &R)
• lightning/src/ln/channelmanager.rs:5432 – update test_check_refresh_async_receive_offer_cache(false) to include peers, channels, router
• lightning/src/onion_message/messenger.rs:2261 and lightning/src/ln/channelmanager.rs:14928 – pass router into handle_offer_paths
• lightning/src/offers/flow.rs:1410 and 1575 – include router in create_static_invoice_for_server calls

🧹 Nitpick comments (8)
lightning/src/ln/onion_utils.rs (2)

1683-1685: New variant name/doc nit and wire-mapping follow-up

  • Wording: “Received payload with unauthenticated payload.” → “Received unauthenticated payload.”
  • If you want remote failure codes (BADONION|PERM|25) to map back to this variant, also include it in impl_from_u16_for_htlc_reason; otherwise code 25 will become UnknownFailureCode.

Suggested doc fix:

-	/// Received payload with unauthenticated payload.
+	/// Received unauthenticated payload.
 	UnauthenticatedPayload,

If desired, add it to the From mapping (see separate comment with diff).


1789-1814: Map code 25 to UnauthenticatedPayload in From

Currently, From won’t return UnauthenticatedPayload; remote BADONION|PERM|25 will be UnknownFailureCode. If that’s unintended, add the variant here.

 impl_from_u16_for_htlc_reason!(
 	LocalHTLCFailureReason,
 	[
 		TemporaryNodeFailure,
 		PermanentNodeFailure,
 		RequiredNodeFeature,
 		InvalidOnionVersion,
 		InvalidOnionHMAC,
 		InvalidOnionKey,
 		TemporaryChannelFailure,
 		PermanentChannelFailure,
 		RequiredChannelFeature,
 		UnknownNextPeer,
 		AmountBelowMinimum,
 		FeeInsufficient,
 		IncorrectCLTVExpiry,
 		CLTVExpiryTooSoon,
 		IncorrectPaymentDetails,
 		FinalIncorrectCLTVExpiry,
 		FinalIncorrectHTLCAmount,
 		ChannelDisabled,
 		CLTVExpiryTooFar,
 		InvalidOnionPayload,
 		MPPTimeout,
-		InvalidOnionBlinding,
+		InvalidOnionBlinding,
+		UnauthenticatedPayload,
 	]
 );
lightning/src/ln/msgs.rs (1)

3594-3594: Fetch receive_auth_key lazily (only for blinded payloads)

Micro-optimization: call get_receive_auth_key() only when decrypting encrypted TLVs.

Apply this refactor in both readers:

-        let receive_auth_key = node_signer.get_receive_auth_key();
@@
-        if let Some(blinding_point) = intro_node_blinding_point.or(update_add_blinding_point) {
+        if let Some(blinding_point) = intro_node_blinding_point.or(update_add_blinding_point) {
+            let receive_auth_key = node_signer.get_receive_auth_key();
             ...
-            match ChaChaDualPolyReadAdapter::read(&mut reader, (rho, receive_auth_key.0))? {
+            match ChaChaDualPolyReadAdapter::read(&mut reader, (rho, receive_auth_key.0))? {

Repeat the same pattern in InboundTrampolinePayload::read.

Also applies to: 3759-3759

lightning/src/ln/blinded_payment_tests.rs (2)

2014-2027: Correct use of ReceiveAuthKey in blinded_hops construction

Using Some(receive_auth_key) for the receive hop is appropriate; the failure branch uses None to simulate auth failure. Consider adding a dedicated negative test case explicitly using a mismatched ReceiveAuthKey to assert failure deterministically.


1369-1374: Rewrite or remove the ignored authentication test

The HMAC/Nonce-era test is now stale. Either delete it or refactor to verify ReceiveAuthKey-based auth failure by constructing the second path with a mismatched key.

Suggested minimal refactor:

@@
-#[ignore]
 fn fails_receive_tlvs_authentication() {
@@
-  let receive_auth_key = chanmon_cfgs[1].keys_manager.get_receive_auth_key();
+  let receive_auth_key = chanmon_cfgs[1].keys_manager.get_receive_auth_key();
@@
   // Test authentication works normally.
@@
   // Swap in a different nonce to force authentication to fail.
   let (_, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[1], Some(amt_msat), None);
-  let payee_tlvs = ReceiveTlvs { ... };
-  // payee_tlvs.authentication.1 = Nonce([0u8; 16]);
+  let payee_tlvs = ReceiveTlvs { 
+    payment_secret,
+    payment_constraints: PaymentConstraints {
+      max_cltv_expiry: u32::max_value(),
+      htlc_minimum_msat: chan_upd.htlc_minimum_msat,
+    },
+    payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}),
+  };
+  // Use a mismatched ReceiveAuthKey to force auth failure:
+  let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);
@@
-  let blinded_path = BlindedPaymentPath::new(
-    &[], nodes[1].node.get_our_node_id(), receive_auth_key,
+  let blinded_path = BlindedPaymentPath::new(
+    &[], nodes[1].node.get_our_node_id(), mismatched_receive_auth_key,
     payee_tlvs, u64::MAX, TEST_FINAL_CLTV as u16,
     &chanmon_cfgs[1].keys_manager, &secp_ctx
   ).unwrap();

This preserves the test intent under the new auth mechanism.

Also applies to: 1384-1392, 1395-1398, 1411-1428

lightning/src/offers/flow.rs (1)

312-317: Do not cache receive_auth_key in OffersMessageFlow

OffersMessageFlow stores the receive_auth_key passed at construction, so any rotations on the underlying NodeSigner won’t be picked up. Consider:

  • invoking node_signer.get_receive_auth_key() on each call to create_blinded_paths instead of using the cached self.receive_auth_key, or
  • adding a setter on OffersMessageFlow to refresh the cached key after rotation.
lightning/src/ln/onion_payment.rs (1)

248-266: Auth gate + logger threading added to create_recv_pending_htlc_info

Good addition of a generic logger and centralized check_authentication closure. Consider raising the log level from trace to info to surface dropped unauthenticated HTLCs.

- log_trace!(logger, "Received an unauthenticated receive payment message");
+ log_info!(logger, "Received an unauthenticated receive payment message");
lightning/src/routing/router.rs (1)

283-291: Update Router trait docs to mention the new receive_auth_key requirement

Docs still reference only tlvs; add a brief note about receive_auth_key being required for authenticated blinded paths.

Apply this doc tweak:

-    /// Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops`
-    /// are assumed to be with the `recipient`'s peers. The payment secret and any constraints are
-    /// given in `tlvs`.
+    /// Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops`
+    /// are assumed to be with the `recipient`'s peers. The payment secret and any constraints are
+    /// given in `tlvs`. The `receive_auth_key` is required to authenticate the blinded payment paths.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d64c86 and 13c4041.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (18 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (13 hunks)
  • lightning/src/ln/channelmanager.rs (9 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (13 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (4 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (9)
lightning/src/util/test_utils.rs (1)
lightning/src/routing/router.rs (14)
  • first_hops (156-205)
  • first_hops (7884-7884)
  • first_hops (7908-7908)
  • first_hops (8311-8311)
  • first_hops (8321-8321)
  • first_hops (8380-8380)
  • first_hops (8540-8540)
  • first_hops (8620-8620)
  • first_hops (8685-8685)
  • first_hops (8739-8739)
  • first_hops (8859-8859)
  • first_hops (8875-8875)
  • first_hops (8887-8887)
  • first_hops (9031-9031)
lightning/src/offers/flow.rs (4)
lightning/src/routing/router.rs (4)
  • create_blinded_payment_paths (129-220)
  • create_blinded_payment_paths (245-253)
  • create_blinded_payment_paths (286-290)
  • a (3617-3617)
lightning/src/util/test_utils.rs (1)
  • create_blinded_payment_paths (290-308)
lightning/src/ln/channelmanager.rs (4)
  • usable_channels (5743-5743)
  • test_create_blinded_payment_paths (12930-12942)
  • check_refresh_async_receive_offer_cache (5409-5428)
  • timer_tick_occurred (7808-8056)
lightning/src/ln/async_payments_tests.rs (1)
  • create_static_invoice_builder (272-306)
lightning/src/ln/max_payment_path_len_tests.rs (2)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/ln/onion_payment.rs (2)
lightning/src/ln/onion_utils.rs (7)
  • shared_secret (2279-2290)
  • new (783-783)
  • new (2164-2164)
  • new (2168-2170)
  • new (2174-2176)
  • new (2731-2733)
  • new (3949-3951)
lightning/src/ln/channelmanager.rs (2)
  • new (3847-3925)
  • new (16114-16135)
lightning/src/ln/blinded_payment_tests.rs (4)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/offers/flow.rs (1)
  • get_receive_auth_key (192-194)
lightning/src/util/test_utils.rs (2)
  • get_receive_auth_key (1730-1732)
  • get_receive_auth_key (1822-1824)
lightning/src/sign/mod.rs (3)
  • get_receive_auth_key (880-880)
  • get_receive_auth_key (2220-2222)
  • get_receive_auth_key (2393-2395)
lightning/src/ln/channelmanager.rs (1)
lightning/src/offers/flow.rs (1)
  • new (118-149)
fuzz/src/invoice_request_deser.rs (1)
lightning/src/offers/static_invoice.rs (3)
  • invoice (801-827)
  • sign (340-353)
  • sign (385-387)
lightning/src/blinded_path/payment.rs (3)
lightning/src/ln/channelmanager.rs (13)
  • new (3847-3925)
  • new (16114-16135)
  • read (612-615)
  • read (662-665)
  • read (1250-1264)
  • read (1497-1499)
  • read (15355-15396)
  • read (15447-15492)
  • read (15497-15544)
  • read (15626-15659)
  • read (15949-15965)
  • read (16164-16170)
  • node (19056-19056)
lightning/src/ln/msgs.rs (8)
  • new (2509-2511)
  • new (2544-2546)
  • read (1147-1171)
  • read (1175-1181)
  • read (3344-3355)
  • read (3404-3408)
  • read (3591-3749)
  • read (3756-3898)
lightning/src/blinded_path/message.rs (1)
  • new (68-85)
lightning/src/ln/msgs.rs (1)
lightning/src/routing/router.rs (1)
  • blinded_path (1761-1768)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: benchmark
  • GitHub Check: semver-checks
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: build-tx-sync (macos-latest, stable)
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: benchmark
  • GitHub Check: semver-checks
  • GitHub Check: build (self-hosted, stable)
🔇 Additional comments (55)
lightning/src/offers/signer.rs (1)

43-51: Reserved HMAC inputs note looks good

Clear reservation of [5], [7], [8] avoids collisions after ReceiveAuthKey adoption. No code action required.

lightning/src/ln/onion_utils.rs (3)

2049-2050: Debug assertion for UnauthenticatedPayload

Asserting empty data for this reason is correct and consistent with other BADONION cases.


1886-1888: Confirm no collisions for new serialization discriminants — verify that 42 and 43 aren’t already used in the ser_failure_reasons! macro.


1726-1727: Confirm no collision with BOLT #4 codes
BADONION | PERM | 25 is not defined in the BOLT #4 failure_code table (code 25 is unassigned/reserved), so using it for UnauthenticatedPayload does not conflict with any existing codes.

lightning/src/ln/msgs.rs (4)

35-35: ChaChaDualPolyReadAdapter + ReceiveTlvs import: LGTM

Adapter swap and imports align with the new authenticated TLV flow.

Also applies to: 59-59


3664-3716: Forward-hop AAD gating and Receive authentication plumbed: LGTM

  • Fails if used_aad on forward hops (correct).
  • Surfaces used_aad on receive as payment_tlvs_authenticated (good).

3812-3863: Trampoline blinded path: AAD gating + flag propagation: LGTM

Mirrors the payment path behavior; looks correct.


2342-2343: Add documentation for payment_tlvs_authenticated
Add a brief doc clarifying that this flag indicates authenticated receive TLVs (via ReceiveAuthKey AAD) and is internal-only:

 pub struct InboundOnionBlindedReceivePayload {
@@
-    pub payment_tlvs_authenticated: bool,
+    /// True if the decrypted receive TLVs were authenticated using our ReceiveAuthKey (AAD).
+    /// Internal-only; not a wire-serialized field.
+    pub payment_tlvs_authenticated: bool,
fuzz/src/chanmon_consistency.rs (1)

130-137: LGTM! Signature updated to match Router trait changes.

The create_blinded_payment_paths method signature correctly adds the _receive_auth_key: ReceiveAuthKey parameter in the expected position, aligning with the broader authentication refactor across the codebase.

lightning/src/ln/async_payments_tests.rs (3)

272-306: LGTM! Simplified authentication flow.

The removal of the entropy parameter and its derivation from create_static_invoice_builder is consistent with the broader refactor where authentication (via ReceiveAuthKey) is now managed internally by the node's keys manager rather than being explicitly threaded through the API.


1861-1861: LGTM! Simplified TLV access pattern.

The change from tlvs.tlvs.payment_constraints.max_cltv_expiry to tlvs.payment_constraints.max_cltv_expiry correctly reflects the structural change from UnauthenticatedReceiveTlvs to ReceiveTlvs, removing unnecessary nesting.


1570-1585: LGTM! Test API simplified.

The removal of the keys_manager parameter from test_create_blinded_payment_paths calls is consistent with the refactor where ReceiveAuthKey is now obtained internally rather than being explicitly passed. This simplifies the test helper API.

lightning/src/ln/max_payment_path_len_tests.rs (2)

13-16: LGTM! Import updated to use new type.

The import change from UnauthenticatedReceiveTlvs to ReceiveTlvs correctly reflects the authentication refactor across the codebase.


215-234: LGTM! Blinded path construction updated correctly.

The changes properly integrate the new authentication flow:

  1. payee_tlvs now uses ReceiveTlvs directly (line 215)
  2. receive_auth_key is obtained from the keys manager (line 223)
  3. BlindedPaymentPath::new receives the receive_auth_key parameter (line 228)

This aligns with the broader authentication refactor replacing nonce-based authentication with ReceiveAuthKey.

fuzz/src/refund_deser.rs (2)

13-21: LGTM! Imports updated for authentication refactor.

The changes correctly update imports to:

  1. Replace UnauthenticatedReceiveTlvs with ReceiveTlvs (line 15)
  2. Add ReceiveAuthKey import (line 21)

These align with the broader authentication refactor across the codebase.


67-109: LGTM! Fuzzing test updated for new authentication flow.

The changes properly integrate the ReceiveAuthKey authentication:

  1. Hardcoded receive_auth_key is appropriate for fuzzing (line 71)
  2. payee_tlvs uses ReceiveTlvs directly (line 73)
  3. Simplified access to payment_constraints (line 90)
  4. BlindedPaymentPath::new correctly receives receive_auth_key parameter (line 102)

The hardcoded key value [41; 32] is acceptable for fuzzing purposes as it provides deterministic behavior for test reproducibility.

lightning/src/ln/blinded_payment_tests.rs (4)

78-96: Good migration to ReceiveTlvs + ReceiveAuthKey in path builder

Constructing ReceiveTlvs and passing receive_auth_key into BlindedPaymentPath::new is correct and matches the new API. No issues.


163-178: Consistent ReceiveAuthKey threading across tests

All call sites build ReceiveTlvs and pass receive_auth_key to BlindedPaymentPath::new. This keeps tests aligned with the new verification. Looks good.

Also applies to: 216-229, 1325-1340, 1394-1398, 1425-1428


1629-1630: Local TestEcdhSigner::get_receive_auth_key implementations are fine

Returning a fixed ReceiveAuthKey for tests/vectors is acceptable. No action needed.

Also applies to: 1942-1942


1-2490: No leftover UnauthenticatedReceiveTlvs references found
Ripgrep search returned zero matches—no action needed.

fuzz/src/invoice_request_deser.rs (1)

86-116: Fuzzer updated correctly for new auth and TLVs

  • Deterministic ReceiveAuthKey is fine for fuzzing.
  • Using ReceiveTlvs and passing receive_auth_key to BlindedPaymentPath::new is correct.

Also applies to: 134-144

lightning/src/util/test_utils.rs (1)

290-307: Router test shim updated to new signature

Adding receive_auth_key and forwarding it maintains parity with DefaultRouter. Looks good.

Also applies to: 297-304

lightning/src/offers/flow.rs (2)

91-96: ReceiveAuthKey ownership in OffersMessageFlow

Storing receive_auth_key and exposing a getter is fine. Construction and use look consistent.

Also applies to: 112-149, 192-195


315-317: Blinded path creation now uses ReceiveAuthKey and ReceiveTlvs

create_blinded_paths delegates receive_key correctly; create_blinded_payment_paths builds ReceiveTlvs and passes receive_auth_key into Router::create_blinded_payment_paths. CLTV math uses saturating_add; looks safe.

Also applies to: 320-356

fuzz/src/full_stack.rs (1)

159-162: Router signature update looks correct

Added ReceiveAuthKey parameter and kept body unreachable! as before. Unused args are properly prefixed with underscores.

lightning/src/ln/onion_payment.rs (4)

283-301: Enforce authentication for BlindedReceive

Early reject on unauthenticated payload before constraint checks is correct and minimizes work/leakage.


316-332: Enforce authentication for TrampolineBlindedReceive

Same proper early reject as above; matches intent for blinded paths.


460-461: Pass logger by reference to decoder

Switch to logger.deref() aligns with generic L: Deref usage; no behavior change.


502-504: Propagate logger into receive-path construction

Updated call and parameter order look correct; passes logger.deref() per new signature.

lightning/src/routing/router.rs (3)

211-214: Consistent fallback call: same note on ReceiveAuthKey ownership

The same ownership consideration for receive_auth_key applies here when constructing the single-hop fallback path.

See the earlier comment for verification steps.


199-205: No change needed: ReceiveAuthKey is Copy
ReceiveAuthKey derives Clone and Copy, so passing it by value across multiple iterations is safe and intended.


129-135: Signature change applied to all create_blinded_payment_paths usages
All Router implementations (including FixedRouter, DefaultRouter, and fuzz routers), test helpers in test_utils.rs, and call sites in offers/flow.rs have been updated to include ReceiveAuthKey and the reordered parameters; no outdated usages remain.

lightning/src/ln/channelmanager.rs (9)

38-38: LGTM: Import consolidation.

The consolidation of blinded_path::payment imports removes duplication and improves code organization.


4884-4884: Logger parameter threaded for enhanced receive path.

The addition of the logger parameter to create_recv_pending_htlc_info enables logging during HTLC receive processing, which is necessary for the ReceiveAuthKey verification flow introduced in this PR.


6995-6995: Consistent logger threading for phantom receives.

The logger parameter addition maintains consistency with the receive path changes, ensuring phantom payment processing also benefits from the enhanced logging and authentication verification.


14815-14815: Node signer parameter enables authentication signing.

The addition of &self.node_signer parameter threads through signing capability needed for ReceiveAuthKey-based authentication in the invoice response flow.


17879-17879: Test imports consolidated.

The import consolidation maintains the necessary test utilities while simplifying the import statement.


18704-18704: Explicit test logger instantiation.

The explicit TestLogger::new() instantiation improves test code clarity and aligns with the consolidated imports.


18726-18726: Test updated for new logger parameter.

The test correctly threads the logger parameter to match the updated function signature, maintaining test coverage of error handling.


18749-18749: Test success case updated consistently.

The success path test correctly includes the logger parameter, ensuring comprehensive test coverage of the updated function signature.


18774-18774: CLTV test updated with inline logger.

The inline TestLogger::new() usage is appropriate for this focused test case and maintains consistency with the updated function signature.

lightning/src/blinded_path/payment.rs (14)

17-17: LGTM! Necessary imports for authentication.

The imports of ChaChaDualPolyReadAdapter and ReceiveAuthKey are required for the new authentication mechanism being introduced.

Also applies to: 27-27


92-110: LGTM! Signature updated to include authentication key.

The receive_auth_key parameter is correctly added and passed through to Self::new.


119-155: LGTM! Method signature and TLV access updated.

The receive_auth_key parameter is correctly added and threaded through to blinded_hops. The direct access to payee_tlvs (line 136) aligns with the simplified ReceiveTlvs structure.


328-335: LGTM! Simplified ReceiveTlvs structure.

The flattened structure removes the nested authentication wrapper, which is now handled at the encryption/decryption level via ReceiveAuthKey. This simplification improves code clarity.


535-573: LGTM! Deserialization correctly enforces required fields.

The Readable implementation for BlindedPaymentTlvs correctly requires all three fields of ReceiveTlvs to be present (lines 567-569).


575-609: LGTM! Consistent deserialization for Trampoline TLVs.

The Readable implementation for BlindedTrampolineTlvs is consistent with BlindedPaymentTlvs and correctly enforces required fields.


616-634: LGTM! Authentication key correctly associated with payee.

The blinded_hops function now associates the ReceiveAuthKey with the payee node (line 623), while intermediate nodes receive None. This correctly implements the authentication model where only the recipient verifies the blinded path.


691-743: LGTM! Updated to use flattened ReceiveTlvs structure.

The compute_payinfo function signature and field access (line 729) are updated to work with the flattened ReceiveTlvs structure.


815-815: LGTM! Test imports updated.

The test imports correctly reflect the type changes.


865-869: LGTM! Test updated for new structure.

The test correctly constructs ReceiveTlvs with all required fields.


883-887: LGTM! Test updated consistently.

The test update is consistent with the new ReceiveTlvs structure.


940-944: LGTM! All test updates consistent.

All remaining tests are updated consistently to use the flattened ReceiveTlvs structure with all required fields.

Also applies to: 999-1003, 1068-1072


509-523: Ensure backward compatibility for ReceiveTlvs TLV changes.

No version‐guarding or migration logic was found around ReceiveTlvs/ReceiveAuthKey. Please manually verify that:

  • Pre-v0.2 LDK nodes gracefully reject or ignore the new TLV fields (12, 65536, 65537) without breaking.
  • Authentication checks still prevent bypassing on older versions.

218-236: Ignore used_aad intentionally: ChaChaDualPolyReadAdapter::read already enforces authenticity via the Poly1305 tag check; the used_aad flag merely indicates which MAC variant matched and can safely be ignored here.

@shaavan
Copy link
Owner Author

shaavan commented Oct 6, 2025

@coderabbitai help

Copy link

coderabbitai bot commented Oct 6, 2025

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@shaavan shaavan force-pushed the aad-payment-review branch from 13c4041 to 694476f Compare October 6, 2025 11:56
@shaavan
Copy link
Owner Author

shaavan commented Oct 6, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Oct 6, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
lightning/src/ln/onion_payment.rs (2)

286-296: Blinded receive constraints compare against upstream CLTV; should use onion’s final cltv (cltv_expiry_height).

For final-hop blinded receipts, PaymentConstraints.max_cltv_expiry should be validated against the onion’s declared final CLTV (cltv_expiry_height), not the HTLC’s msg.cltv_expiry. Using the upstream value can spuriously fail valid payments or accept invalid ones when they differ.

Apply this fix:

-			check_blinded_payment_constraints(
-				sender_intended_htlc_amt_msat, cltv_expiry, &payment_constraints
-			)
+			check_blinded_payment_constraints(
+				sender_intended_htlc_amt_msat, cltv_expiry_height, &payment_constraints
+			)

318-327: Same issue in trampoline-blinded receive: compare constraints to cltv_expiry_height.

Validate PaymentConstraints against the onion’s final CLTV height, not msg.cltv_expiry.

-			check_blinded_payment_constraints(
-				sender_intended_htlc_amt_msat, cltv_expiry, &payment_constraints,
-			)
+			check_blinded_payment_constraints(
+				sender_intended_htlc_amt_msat, cltv_expiry_height, &payment_constraints,
+			)
lightning/src/ln/blinded_payment_tests.rs (1)

1455-1458: Align expected failure with UnauthenticatedPayload.

Runtime now returns LocalHTLCFailureReason::UnauthenticatedPayload for auth failures. Update the assertion:

-		PaymentFailedConditions::new().expected_htlc_error_data(LocalHTLCFailureReason::InvalidOnionPayload, &[]),
+		PaymentFailedConditions::new().expected_htlc_error_data(LocalHTLCFailureReason::UnauthenticatedPayload, &[]),
lightning/src/offers/flow.rs (1)

91-94: Avoid stale ReceiveAuthKey: handle key rotation

OffersMessageFlow stores ReceiveAuthKey by value. If the NodeSigner rotates this key, newly decoded inbound onions will use the fresh key, while paths built here will still embed/expect the old key, breaking authentication.

Mitigations:

  • Fetch the key at use-sites instead of storing (plumb NodeSigner or a getter into the flow), or
  • Store receive_auth_key behind a Mutex/RwLock and expose a setter to update on rotation, and ensure all path-creation calls read the latest value.

At minimum, document that the key must be stable for the lifetime of generated paths.

♻️ Duplicate comments (1)
lightning/src/routing/router.rs (1)

183-185: Still need saturating_add for max_cltv_expiry.

Switching to checked_add just drops the hop when the addition overflows, which is the same overflow hazard previously flagged. Per the earlier review you should call saturating_add (after casting the delta if needed) so the route stays valid without wrapping.

🧹 Nitpick comments (5)
lightning/src/ln/channelmanager.rs (1)

18774-18774: Consider using a named logger variable for consistency.

While the inline &TestLogger::new() works correctly, other tests in this file create a named logger variable (see lines 18704, 18726, 18749). For consistency and slightly better readability, consider following the same pattern.

Apply this diff to align with the pattern used in other tests:

+	let logger = TestLogger::new();
 	}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, current_height, &TestLogger::new());
+	}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, current_height, &logger);
lightning/src/ln/onion_payment.rs (1)

256-266: Log level for unauthenticated payloads.

Consider warn instead of info for unauthenticated receive payloads to aid ops triage.

-			log_info!(logger, "Received an unauthenticated receive payment message");
+			log_warn!(logger, "Received an unauthenticated receive payment message");
lightning/src/ln/blinded_payment_tests.rs (1)

1369-1372: Remove stale comment; the test now targets ReceiveAuthKey-based auth.

These lines suggest redundancy post-(HMAC, Nonce) removal. The test has been adapted to ReceiveAuthKey. Drop the comment to avoid confusion.

lightning/src/blinded_path/payment.rs (2)

612-614: Nit: fix comment typo

“payment bilnded path's” → “payment blinded path’s”.

Apply:

-/// Represents the padding round off size (in bytes) that
-/// is used to pad payment bilnded path's [`BlindedHop`]
+/// Represents the padding round-off size (in bytes) used to pad payment blinded path's [`BlindedHop`].

101-101: Style: prefer u64::MAX over u64::max_value()

Idiomatic Rust uses u64::MAX. Optional consistency cleanup.

-        let htlc_maximum_msat = u64::max_value();
+        let htlc_maximum_msat = u64::MAX;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13c4041 and 694476f.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (18 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (13 hunks)
  • lightning/src/ln/channelmanager.rs (9 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (12 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (5 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • lightning/src/offers/signer.rs
  • lightning/src/ln/msgs.rs
  • lightning/src/ln/async_payments_tests.rs
  • lightning/src/ln/onion_utils.rs
  • fuzz/src/invoice_request_deser.rs
🧰 Additional context used
🧬 Code graph analysis (8)
lightning/src/ln/channelmanager.rs (1)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/util/test_utils.rs (1)
lightning/src/routing/router.rs (14)
  • first_hops (156-207)
  • first_hops (7886-7886)
  • first_hops (7910-7910)
  • first_hops (8313-8313)
  • first_hops (8323-8323)
  • first_hops (8382-8382)
  • first_hops (8542-8542)
  • first_hops (8622-8622)
  • first_hops (8687-8687)
  • first_hops (8741-8741)
  • first_hops (8861-8861)
  • first_hops (8877-8877)
  • first_hops (8889-8889)
  • first_hops (9033-9033)
lightning/src/ln/onion_payment.rs (1)
lightning/src/ln/channel.rs (6)
  • new (1091-1093)
  • new (1205-1214)
  • new (12825-12876)
  • new (13190-13241)
  • None (11074-11074)
  • None (14118-14118)
lightning/src/routing/router.rs (4)
lightning/src/offers/flow.rs (1)
  • create_blinded_payment_paths (322-356)
fuzz/src/chanmon_consistency.rs (1)
  • create_blinded_payment_paths (130-136)
fuzz/src/full_stack.rs (1)
  • create_blinded_payment_paths (158-164)
lightning/src/util/test_utils.rs (1)
  • create_blinded_payment_paths (290-308)
lightning/src/ln/blinded_payment_tests.rs (4)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/offers/flow.rs (1)
  • get_receive_auth_key (192-194)
lightning/src/util/test_utils.rs (2)
  • get_receive_auth_key (1730-1732)
  • get_receive_auth_key (1822-1824)
lightning/src/sign/mod.rs (3)
  • get_receive_auth_key (880-880)
  • get_receive_auth_key (2220-2222)
  • get_receive_auth_key (2393-2395)
lightning/src/blinded_path/payment.rs (3)
lightning/src/ln/channelmanager.rs (13)
  • new (3847-3925)
  • new (16114-16135)
  • read (612-615)
  • read (662-665)
  • read (1250-1264)
  • read (1497-1499)
  • read (15355-15396)
  • read (15447-15492)
  • read (15497-15544)
  • read (15626-15659)
  • read (15949-15965)
  • read (16164-16170)
  • node (19056-19056)
lightning/src/ln/msgs.rs (8)
  • new (2509-2511)
  • new (2544-2546)
  • read (1147-1171)
  • read (1175-1181)
  • read (3344-3355)
  • read (3404-3408)
  • read (3591-3749)
  • read (3756-3898)
lightning/src/blinded_path/message.rs (1)
  • new (68-85)
lightning/src/ln/max_payment_path_len_tests.rs (2)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/offers/flow.rs (4)
lightning/src/routing/router.rs (4)
  • create_blinded_payment_paths (129-222)
  • create_blinded_payment_paths (247-255)
  • create_blinded_payment_paths (288-292)
  • a (3619-3619)
lightning/src/util/test_utils.rs (1)
  • create_blinded_payment_paths (290-308)
lightning/src/ln/channelmanager.rs (4)
  • usable_channels (5743-5743)
  • test_create_blinded_payment_paths (12930-12942)
  • check_refresh_async_receive_offer_cache (5409-5428)
  • timer_tick_occurred (7808-8056)
lightning/src/ln/async_payments_tests.rs (1)
  • create_static_invoice_builder (272-306)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: benchmark
  • GitHub Check: linting
  • GitHub Check: benchmark
  • GitHub Check: check_release
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: semver-checks
  • GitHub Check: benchmark
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: build-tx-sync (macos-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, 1.75.0)
  • GitHub Check: build-tx-sync (macos-latest, beta)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: semver-checks
🔇 Additional comments (13)
lightning/src/ln/channelmanager.rs (2)

4881-4884: LGTM!

The logger parameter addition follows standard Rust patterns for passing logger references.


14814-14816: Approve router parameter addition
The Router trait already provides the necessary methods (including blinded‐path auth via create_blinded_payment_paths) and find_route for invoice responses, so passing &self.router here is correct.

lightning/src/ln/onion_payment.rs (1)

460-504: Logger deref plumbed correctly.

Passing logger.deref() into decode_incoming_update_add_htlc_onion and create_recv_pending_htlc_info aligns with the new generic constraints.

lightning/src/ln/blinded_payment_tests.rs (1)

78-96: ReceiveTlvs and ReceiveAuthKey adoption looks correct.

Construction of ReceiveTlvs, retrieval of receive_auth_key, and passing it into BlindedPaymentPath::new are consistent with the new API.

Also applies to: 161-178, 216-230, 333-341

fuzz/src/chanmon_consistency.rs (1)

130-134: Router API updated coherently.

The additional ReceiveAuthKey and ReceiveTlvs in create_blinded_payment_paths match the new flow. No issues.

lightning/src/ln/max_payment_path_len_tests.rs (1)

213-234: Blinded path setup updated correctly.

Using ReceiveTlvs and injecting receive_auth_key into BlindedPaymentPath::new is correct.

fuzz/src/refund_deser.rs (1)

71-81: LGTM on ReceiveAuthKey/ReceiveTlvs integration.

Fuzz harness creates ReceiveTlvs and threads receive_auth_key into BlindedPaymentPath::new correctly.

Also applies to: 100-109

lightning/src/util/test_utils.rs (1)

290-309: LGTM! Signature update aligns with Router trait changes.

The create_blinded_payment_paths method correctly adds receive_auth_key as the second parameter and properly forwards it to the underlying router in both execution paths (with and without expected paths). The parameter ordering matches the pattern established in the codebase.

fuzz/src/full_stack.rs (1)

158-164: LGTM! Fuzz router stub correctly updated.

The signature change adds _receive_auth_key as the second parameter to match the Router trait's updated interface. The _ prefix correctly indicates the parameter is unused in this stub implementation.

lightning/src/blinded_path/payment.rs (2)

618-624: Good: ReceiveAuthKey applied only to payee hop

Passing Some(local_node_receive_key) only for the final (receive) hop aligns with authenticating the receiver context without burdening forward hops.


227-234: Enforced AAD for payee hop decryption Verified construct_blinded_hops passes the payee’s ReceiveAuthKey to encrypt_payload as AAD and ChaChaDualPolyReadAdapter::read uses it on decryption, ensuring authentication.

lightning/src/offers/flow.rs (2)

320-356: Router plumbing for ReceiveAuthKey looks correct

Passing receive_auth_key through to Router::create_blinded_payment_paths and building ReceiveTlvs in-flow is coherent with the new auth model.

Please re-run impacted tests/fuzzers touching blinded payment path creation to ensure no regressions in path count/eligibility and inbound auth.


1399-1400: Signatures updated to thread Router where needed

check_refresh_static_invoices and create_static_invoice_for_server correctly accept a router and reuse it downstream. No issues found.

Also applies to: 1615-1617

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
lightning/src/offers/flow.rs (3)

812-866: Breaking API change: Additional parameters required.

The addition of router: &R and usable_channels: Vec<ChannelDetails> parameters is a breaking change. Callers will need to update their invocations to provide routing information and channel details, which are necessary for creating authenticated blinded payment paths.

This change aligns with the PR's authentication objectives and is correctly implemented.


941-1017: Breaking API change: Additional parameters required.

Similar to create_static_invoice_builder, this method now requires router: &R and usable_channels: Vec<ChannelDetails> parameters. Callers must be updated accordingly.

The implementation correctly uses these parameters to create authenticated blinded payment paths.


1323-1345: Inconsistent router parameter passing pattern.

This method takes router: R (by value), while other public methods like create_static_invoice_builder (line 812) and create_response_for_invoice_request (line 941) take router: &R (by reference). Taking the router by value prevents callers from reusing it, which could be problematic.

Consider changing the signature to accept router: &R for consistency:

 	pub fn check_refresh_async_receive_offer_cache<R: Deref>(
-		&self, peers: Vec<MessageForwardNode>, usable_channels: Vec<ChannelDetails>, router: R,
+		&self, peers: Vec<MessageForwardNode>, usable_channels: Vec<ChannelDetails>, router: &R,
 		timer_tick_occurred: bool,
 	) -> Result<(), ()>

Then update line 1341 to pass &router instead of router, and adjust the private method check_refresh_static_invoices signature similarly.

🧹 Nitpick comments (5)
lightning/src/ln/channelmanager.rs (1)

18774-18774: Consider extracting TestLogger for consistency.

The inline TestLogger::new() creation is less readable than the variable approach used at line 18704. For consistency and readability, consider extracting it to a variable.

Apply this diff:

+	let logger = TestLogger::new();
 	}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, current_height, 
-	&TestLogger::new());
+	&logger);
lightning/src/blinded_path/payment.rs (1)

509-513: Clarify the comment about TLV field reuse.

The comment states that authentication TLV fields were "removed in LDK v0.2" and can now be reused. However, it's unclear:

  1. What specific TLV field numbers are being reused
  2. Whether there are any backward compatibility concerns
  3. Whether old nodes might still send the old authentication TLVs

Consider expanding the comment to specify the exact TLV field numbers and any compatibility considerations.

lightning/src/ln/blinded_payment_tests.rs (1)

1369-1372: Remove or reword the redundant TODO-style comment.

The block suggests the test is redundant, but the test below actively validates ReceiveAuthKey-based auth failure. Drop the comment to avoid confusion.

Apply this diff to remove the comment:

-/// This test became redundant after removing (HMAC, Nonce)-based verification.
-/// After review, we can either remove it entirely or update it to work with
-/// ReceiveAuthKey-based verification.
lightning/src/ln/msgs.rs (2)

3651-3716: Blinded payment decode: AAD gating and auth propagation.

  • Using ChaChaDualPolyReadAdapter with (rho, receive_auth_key) is right.
  • Rejecting Forward when used_aad is true is correct.
  • Propagating used_aad into payment_tlvs_authenticated is good.

Optional: consider a more specific DecodeError (or log) when AAD/auth fails to aid debugging; InvalidValue is generic.

Ensure send-side uses AAD only for Receive TLVs to preserve interop.


3758-3759: Defer get_receive_auth_key() in trampoline path to avoid unnecessary work.

Only needed for blinded branches. Move the call inside the if let Some(blinding_point) block (after computing rho), mirroring the non-trampoline path.

Apply this diff near the start of InboundTrampolinePayload::read:

-        let receive_auth_key = node_signer.get_receive_auth_key();
@@
-            let mut s = Cursor::new(&enc_tlvs);
+            let receive_auth_key = node_signer.get_receive_auth_key();
+            let mut s = Cursor::new(&enc_tlvs);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d64c86 and 694476f.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (18 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (13 hunks)
  • lightning/src/ln/channelmanager.rs (9 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (12 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (5 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, beta)
  • GitHub Check: build-tx-sync (macos-latest, 1.75.0)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (windows-latest, stable)
🔇 Additional comments (50)
lightning/src/offers/signer.rs (1)

39-50: Approve changes

No active references remain to the deprecated functions or types; only the commented-out constant persists.

lightning/src/ln/async_payments_tests.rs (2)

1861-1861: LGTM! Simplified access pattern aligns with ReceiveTlvs refactoring.

The change from the nested structure (tlvs.tlvs.payment_constraints.max_cltv_expiry) to the flattened structure (tlvs.payment_constraints.max_cltv_expiry) is correct and consistent with the broader refactor introducing ReceiveTlvs in place of UnauthenticatedReceiveTlvs.


1861-1861: All BlindedPaymentTlvs::Receive usages updated; no ​.tlvs​.tlvs​ remains

lightning/src/offers/flow.rs (7)

26-26: LGTM! Import change aligns with authentication enforcement.

The change to import ReceiveTlvs (instead of UnauthenticatedReceiveTlvs) correctly supports the PR's goal of enforcing authentication for blinded payment paths.


91-91: LGTM! Field addition is correct.

The receive_auth_key field is properly stored and used throughout the implementation for authenticating blinded payment paths.


192-194: LGTM! Getter method is correctly implemented.

The get_receive_auth_key method provides clean access to the authentication key.


322-356: Authentication enforcement implemented correctly.

The changes correctly:

  1. Retrieve receive_auth_key from the struct (line 331)
  2. Use ReceiveTlvs instead of UnauthenticatedReceiveTlvs (line 342), enforcing authentication
  3. Pass the authentication key to the router (line 350)

This properly implements the PR's objective of adding authentication to blinded payment paths.


361-377: LGTM! Test method correctly updated.

The test wrapper method signature correctly matches the updated private method.


1398-1456: LGTM! Private method correctly updated.

The addition of usable_channels and router parameters enables the method to create authenticated blinded payment paths. The implementation correctly passes these parameters to create_static_invoice_for_server.


1614-1661: LGTM! Private method correctly updated.

The addition of the usable_channels parameter and the use of receive_auth_key throughout the method correctly enable creation of authenticated static invoices with proper blinded payment paths.

lightning/src/ln/channelmanager.rs (3)

38-38: LGTM!

The import of payment context types aligns with the PR's authentication enhancements for blinded payment paths.


14815-14816: Signature alignment confirmed: The arguments (&self.node_signer, &self.router, invoice_request, amount_msats, payment_hash, payment_secret, self.list_usable_channels()) match the create_response_for_invoice_request definition in flow.rs.


4884-4884: All create_recv_pending_htlc_info invocations include the logger argument.

lightning/src/ln/onion_payment.rs (6)

248-255: Function signature changes look correct.

The addition of the logger parameter with appropriate bounds enables logging within the authentication checks, which improves observability for security-sensitive operations.


282-284: Authentication check properly enforced for blinded receive payloads.

The authentication check is correctly invoked for InboundOnionBlindedReceivePayload, ensuring that unauthenticated receive payments are rejected.


313-316: Authentication check properly enforced for trampoline blinded receive payloads.

The authentication check is correctly invoked for InboundOnionBlindedReceivePayload within trampoline receive, ensuring consistent security across both standard and trampoline paths.


460-460: Logger correctly threaded to onion decoding.

The logger is now passed to decode_incoming_update_add_htlc_onion, enabling logging within the decoding process.


502-503: Parameters correctly aligned in create_recv_pending_htlc_info call

The last five arguments (None, allow_skimmed_fees, msg.skimmed_fee_msat, cur_height, logger.deref()) map precisely to phantom_shared_secret, allow_underpay, counterparty_skimmed_fee_msat, current_height, and logger in the signature.


256-266: Verify failure_code mapping for UnauthenticatedPayload
It’s currently set to BADONION | PERM | 25—confirm this aligns with the BOLT 4 failure code for an unauthenticated onion payload.

lightning/src/blinded_path/payment.rs (10)

17-17: Import addition is used correctly.

The ChaChaDualPolyReadAdapter import is utilized in line 232 for authenticated deserialization.


27-27: Import addition is used correctly.

The ReceiveAuthKey import is threaded through multiple functions and used for authentication in the deserialization process.


92-110: ReceiveAuthKey correctly threaded through one-hop path creation.

The receive_auth_key parameter is properly passed through to the new function, ensuring authentication is enforced for one-hop blinded payment paths.


119-155: ReceiveAuthKey correctly integrated into multi-hop path creation.

The receive_auth_key is properly passed to both compute_payinfo (line 136, as a reference to payee_tlvs which contains it implicitly) and blinded_hops (line 150), ensuring authentication is enforced throughout the path construction.


227-235: Authentication key correctly retrieved and used in deserialization.

The receive_auth_key is obtained from the node_signer and passed to ChaChaDualPolyReadAdapter::read for authenticated decryption. This ensures that only the intended recipient with the correct authentication key can decrypt the payload.


567-570: Deserialization correctly enforces required fields.

The BlindedPaymentTlvs::Receive variant now properly requires payment_secret, payment_constraints, and payment_context, returning DecodeError::InvalidValue if any are missing. This is consistent with the new authentication model where these fields must be present and authenticated.


603-606: Deserialization correctly enforces required fields for trampoline paths.

Similar to the standard receive path, the BlindedTrampolineTlvs::Receive variant now properly requires all three fields, ensuring consistency across both path types.


618-623: ReceiveAuthKey correctly integrated into blinded hops construction.

The local_node_receive_key parameter is properly paired with the payee_node_id in line 623, ensuring that the final hop in the blinded path can authenticate the payload.


692-692: Function signature change maintains consistency.

The compute_payinfo function now takes payee_tlvs: &ReceiveTlvs as a reference, which is consistent with the new type system where ReceiveTlvs replaces the previous unauthenticated variant.


815-815: Test code properly updated to use ReceiveTlvs.

All test cases have been updated to construct ReceiveTlvs with the required fields (payment_secret, payment_constraints, and payment_context), ensuring tests reflect the new authentication model.

Also applies to: 865-869, 883-887, 940-944, 999-1003, 1068-1072

lightning/src/ln/blinded_payment_tests.rs (7)

20-20: Imports updated for ReceiveTlvs/ReceiveAuthKey look correct.

No issues spotted.


163-179: One‑hop path test updated properly.

New ReceiveTlvs + receive_auth_key usage is consistent.


216-229: MPP one‑hop path update looks good.

Correct parameter order and key retrieval.


1325-1340: Custom TLVs test aligned with new API.

Correctly uses ReceiveTlvs and passes receive_auth_key.


2014-2027: Trampoline single‑hop receive: auth key threaded correctly.

Passing Some(receive_auth_key) into construct_blinded_hops is consistent with the new flow.


1629-1630: Test node signer updated to return ReceiveAuthKey.

Matches new trait requirements.

Also applies to: 1942-1943


78-96: All BlindedPaymentPath::new call sites updated with receive_auth_key
No deprecated UnauthenticatedReceiveTlvs found; every BlindedPaymentPath::new(…) invocation now includes the new receive_auth_key parameter.

lightning/src/ln/max_payment_path_len_tests.rs (2)

15-16: Import switch to ReceiveTlvs is correct.

No other changes needed here.


215-234: Blinded path setup updated correctly.

  • ReceiveTlvs built with expected fields.
  • receive_auth_key fetched and passed in the new position to BlindedPaymentPath::new.
fuzz/src/chanmon_consistency.rs (2)

131-134: Router::create_blinded_payment_paths signature updated.

ReceiveAuthKey parameter added; body remains unreachable as before. OK.


352-354: NodeSigner now implements get_receive_auth_key.

Conforms with updated trait.

fuzz/src/invoice_request_deser.rs (2)

15-16: Imports updated for ReceiveTlvs/ReceiveAuthKey.

Consistent with new APIs.

Also applies to: 23-23


86-87: Invoice response builder updated correctly for authenticated receive.

  • Adds a deterministic ReceiveAuthKey for fuzzing.
  • Uses ReceiveTlvs and passes receive_auth_key to BlindedPaymentPath::new.
  • Adjusted field access on payment_constraints is correct.

Also applies to: 108-116, 125-125, 135-144

fuzz/src/full_stack.rs (2)

159-162: Router::create_blinded_payment_paths signature updated.

ReceiveAuthKey parameter added; consistent with broader changes.


442-444: KeyProvider implements get_receive_auth_key.

Aligns with trait changes.

lightning/src/util/test_utils.rs (1)

290-309: LGTM! Signature updated to include ReceiveAuthKey.

The create_blinded_payment_paths method signature correctly adds receive_auth_key: ReceiveAuthKey as the second parameter and threads it through to the underlying router call, aligning with the broader refactor to authenticate blinded payment paths.

fuzz/src/refund_deser.rs (2)

13-22: LGTM! Imports updated for ReceiveTlvs and ReceiveAuthKey.

The import changes correctly reflect the shift from UnauthenticatedReceiveTlvs to ReceiveTlvs and add the necessary ReceiveAuthKey import for the new authentication flow.


67-109: LGTM! Fuzz test updated to use ReceiveTlvs and ReceiveAuthKey.

The changes correctly:

  • Initialize receive_auth_key with test data ([41; 32])
  • Construct payee_tlvs as ReceiveTlvs instead of UnauthenticatedReceiveTlvs
  • Update field access from payee_tlvs.tlvs().payment_constraints to payee_tlvs.payment_constraints, reflecting the new direct field structure
  • Thread receive_auth_key through to BlindedPaymentPath::new

The hardcoded test values are appropriate for fuzzing.

lightning/src/ln/msgs.rs (3)

35-35: Import of ReceiveTlvs is correct for new Receive adapter path.

No issues.


59-59: Switch to ChaChaDualPolyReadAdapter looks good.

Fits the new auth/AAD flow.


3812-3863: Trampoline blinded decode mirrors payment path; AAD check and propagation LGTM.

Symmetric handling of used_aad and payment_tlvs_authenticated is correct.

  • Verify NodeSigner provides stable/rotated ReceiveAuthKey semantics as intended.
  • Confirm no legacy senders set AAD on forward trampoline TLVs; otherwise this becomes a breaking change.

Comment on lines +1412 to 1419
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
max_cltv_expiry: u32::max_value(),
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}),
};
let nonce = Nonce([43u8; 16]);
let mut payee_tlvs = payee_tlvs.authenticate(nonce, &expanded_key);
payee_tlvs.authentication.1 = Nonce([0u8; 16]);
// Use a mismatched ReceiveAuthKey to force auth failure:
let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Make mismatched key derivation robust.

Using ReceiveAuthKey([0;32]) could theoretically match the node’s key if it ever returns zeros. Safer: flip a bit of the real key to guarantee mismatch.

-// Use a mismatched ReceiveAuthKey to force auth failure:
-let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);
+// Use a guaranteed-mismatched ReceiveAuthKey to force auth failure:
+let mut real = chanmon_cfgs[1].keys_manager.get_receive_auth_key().0;
+real[0] ^= 0x01;
+let mismatched_receive_auth_key = ReceiveAuthKey(real);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
max_cltv_expiry: u32::max_value(),
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}),
};
let nonce = Nonce([43u8; 16]);
let mut payee_tlvs = payee_tlvs.authenticate(nonce, &expanded_key);
payee_tlvs.authentication.1 = Nonce([0u8; 16]);
// Use a mismatched ReceiveAuthKey to force auth failure:
let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
max_cltv_expiry: u32::max_value(),
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}),
};
// Use a guaranteed-mismatched ReceiveAuthKey to force auth failure:
let mut real = chanmon_cfgs[1].keys_manager.get_receive_auth_key().0;
real[0] ^= 0x01;
let mismatched_receive_auth_key = ReceiveAuthKey(real);
🤖 Prompt for AI Agents
In lightning/src/ln/blinded_payment_tests.rs around lines 1412 to 1422, creating
the mismatched ReceiveAuthKey with ReceiveAuthKey([0u8; 32]) is unsafe because
an all-zero key could theoretically match; instead construct the mismatched key
by cloning the actual receive_auth_key bytes and flipping a single bit (e.g.,
XOR one byte with 0x01) to guarantee a different value; replace the zeroed array
with a derived variant from the real key so the mismatch is deterministic and
provably not equal.

Comment on lines +2342 to 2343
pub payment_tlvs_authenticated: bool,
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

New field payment_tlvs_authenticated added to blinded receive payload.

Good addition. Please add a brief doc comment clarifying semantics (true when payment TLVs were authenticated using ReceiveAuthKey). Also verify no external code destructures this struct without .. as this is a source-compatible change only if not destructured exhaustively.

Run to verify usages:


🏁 Script executed:

#!/bin/bash
# Confirm NodeSigner has the new API and check destructuring of InboundOnionBlindedReceivePayload
rg -n -C2 'trait\s+NodeSigner\b|impl\s+NodeSigner\b|get_receive_auth_key' --type=rust
rg -n -C2 'InboundOnionBlindedReceivePayload\s*\{' --type=rust

Length of output: 28194


Add doc comment for payment_tlvs_authenticated
Document that this flag is true when payment TLVs were authenticated using ReceiveAuthKey. No external code exhaustively destructures InboundOnionBlindedReceivePayload, so this addition remains source-compatible.

🤖 Prompt for AI Agents
In lightning/src/ln/msgs.rs around lines 2342 to 2343, add a Rust doc comment
for the struct field `payment_tlvs_authenticated` explaining that the flag is
true when payment TLVs were authenticated using `ReceiveAuthKey`; insert a ///
doc line immediately above the field with that text (or similar concise
wording), keeping the comment-only change to remain source-compatible.

@shaavan shaavan force-pushed the aad-payment-review branch from 694476f to 1c3d125 Compare October 6, 2025 12:42
@shaavan
Copy link
Owner Author

shaavan commented Oct 6, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Oct 6, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
lightning/src/ln/blinded_payment_tests.rs (1)

1417-1418: This issue was already flagged in a previous review.

Using ReceiveAuthKey([0u8; 32]) is unsafe as it could theoretically match the node's actual key if it ever returns zeros. The previous review comment suggests deriving the mismatched key from the real key by flipping a bit to guarantee mismatch.

lightning/src/ln/msgs.rs (1)

2342-2343: Doc comment for payment_tlvs_authenticated is still missing.

The earlier review asked for a brief doc explaining when this flag is set. Please add the comment so downstream users know it’s true only when the TLVs were authenticated with ReceiveAuthKey.

 		pub custom_tlvs: Vec<(u64, Vec<u8>)>,
-		pub payment_tlvs_authenticated: bool,
+		/// True if the decrypted payment TLVs were authenticated with `ReceiveAuthKey`.
+		pub payment_tlvs_authenticated: bool,
lightning/src/routing/router.rs (1)

183-185: Overflow-safe CLTV aggregation: resolved with saturating_add

Using saturating_add prevents u32 overflow and avoids silently dropping candidates. Good fix.

🧹 Nitpick comments (4)
lightning/src/ln/max_payment_path_len_tests.rs (1)

15-16: Migration to ReceiveTlvs + ReceiveAuthKey — LGTM

Imports, TLVs construction, and BlindedPaymentPath::new call updated correctly. Minor nit: secp_ctx needn’t be mut.

Apply:

- let mut secp_ctx = Secp256k1::new();
+ let secp_ctx = Secp256k1::new();

Also applies to: 216-235

fuzz/src/invoice_request_deser.rs (1)

24-24: ReceiveAuthKey threading + ReceiveTlvs migration — LGTM

Fuzzer compiles against new API and uses ReceiveAuthKey consistently. Optional: derive the key via a NodeSigner in future to mirror production paths; not required for fuzzing.

Also applies to: 86-87, 108-116, 125-126, 137-143

fuzz/src/refund_deser.rs (1)

21-22: ReceiveTlvs + ReceiveAuthKey adoption — LGTM

Consistent with crate-wide API changes. Optional: consider deriving ReceiveAuthKey from a signer for higher fidelity; fine as-is for fuzzing.

Also applies to: 71-72, 73-80, 90-91, 102-103

lightning/src/routing/router.rs (1)

287-293: Trait docs/signature reflect authentication requirement

Docs and Router trait updated coherently. Consider noting this as a breaking change in release notes/changelog.

Confirm downstream crates are updated to the new trait signature.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 694476f and 1c3d125.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (17 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (13 hunks)
  • lightning/src/ln/channelmanager.rs (10 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (12 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (6 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • lightning/src/ln/async_payments_tests.rs
  • lightning/src/util/test_utils.rs
  • fuzz/src/chanmon_consistency.rs
🧰 Additional context used
🧬 Code graph analysis (9)
lightning/src/ln/blinded_payment_tests.rs (4)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/offers/flow.rs (1)
  • get_receive_auth_key (192-194)
lightning/src/util/test_utils.rs (2)
  • get_receive_auth_key (1730-1732)
  • get_receive_auth_key (1822-1824)
lightning/src/sign/mod.rs (3)
  • get_receive_auth_key (880-880)
  • get_receive_auth_key (2220-2222)
  • get_receive_auth_key (2393-2395)
lightning/src/ln/max_payment_path_len_tests.rs (3)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/ln/channelmanager.rs (2)
  • new (3847-3925)
  • new (16114-16135)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/ln/onion_payment.rs (1)
lightning/src/ln/onion_utils.rs (1)
  • shared_secret (2281-2292)
lightning/src/ln/msgs.rs (1)
lightning/src/ln/channelmanager.rs (13)
  • new (3847-3925)
  • new (16114-16135)
  • read (612-615)
  • read (662-665)
  • read (1250-1264)
  • read (1497-1499)
  • read (15355-15396)
  • read (15447-15492)
  • read (15497-15544)
  • read (15626-15659)
  • read (15949-15965)
  • read (16164-16170)
  • read (16197-17856)
lightning/src/ln/channelmanager.rs (1)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/blinded_path/payment.rs (3)
lightning/src/ln/channelmanager.rs (13)
  • new (3847-3925)
  • new (16114-16135)
  • read (612-615)
  • read (662-665)
  • read (1250-1264)
  • read (1497-1499)
  • read (15355-15396)
  • read (15447-15492)
  • read (15497-15544)
  • read (15626-15659)
  • read (15949-15965)
  • read (16164-16170)
  • node (19057-19057)
lightning/src/ln/msgs.rs (8)
  • new (2509-2511)
  • new (2544-2546)
  • read (1147-1171)
  • read (1175-1181)
  • read (3344-3355)
  • read (3404-3408)
  • read (3591-3749)
  • read (3756-3898)
lightning/src/blinded_path/message.rs (3)
  • new (68-85)
  • blinded_hops (171-173)
  • blinded_hops (693-733)
lightning/src/routing/router.rs (4)
lightning/src/offers/flow.rs (1)
  • create_blinded_payment_paths (322-356)
fuzz/src/chanmon_consistency.rs (1)
  • create_blinded_payment_paths (130-136)
fuzz/src/full_stack.rs (1)
  • create_blinded_payment_paths (158-164)
lightning/src/util/test_utils.rs (1)
  • create_blinded_payment_paths (290-308)
fuzz/src/invoice_request_deser.rs (1)
lightning/src/offers/static_invoice.rs (3)
  • invoice (801-827)
  • sign (340-353)
  • sign (385-387)
lightning/src/offers/flow.rs (3)
lightning/src/routing/router.rs (4)
  • create_blinded_payment_paths (129-222)
  • create_blinded_payment_paths (247-255)
  • create_blinded_payment_paths (288-292)
  • a (3619-3619)
lightning/src/util/test_utils.rs (1)
  • create_blinded_payment_paths (290-308)
lightning/src/ln/channelmanager.rs (4)
  • usable_channels (5743-5743)
  • test_create_blinded_payment_paths (12930-12942)
  • check_refresh_async_receive_offer_cache (5409-5428)
  • timer_tick_occurred (7808-8056)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: linting
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: benchmark
  • GitHub Check: semver-checks
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: build-tx-sync (macos-latest, 1.75.0)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, beta)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, stable)
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: benchmark
  • GitHub Check: linting
  • GitHub Check: check_release
  • GitHub Check: semver-checks
🔇 Additional comments (39)
lightning/src/offers/signer.rs (1)

43-50: Legacy HMAC references fully removed; confirm version mention.

All removed HMAC functions and constants no longer appear in code, and tests use ReceiveAuthKey/ReceiveTlvs as expected. Verify that “LDK v0.2” is correctly referenced in changelogs or docs:

#!/bin/bash
echo "=== Searching for 'LDK v0.2' across repository ==="
rg -n 'LDK v0.2'
lightning/src/ln/channelmanager.rs (6)

38-38: LGTM!

Import addition for payment context types aligns with the PR's ReceiveAuthKey integration.


6995-6995: Logger parameter added for phantom receive processing.

Consistent with the previous change, adding &*self.logger enables logging during phantom receive creation.


17879-17879: LGTM!

Test utility import updated to support the test modifications below.


18704-18704: Test updates align with function signature changes.

The tests correctly create TestLogger instances and pass references to match the updated function signatures. The pattern of creating owned loggers in tests (let logger = TestLogger::new()) and passing direct references (&logger) is appropriate and differs correctly from production code's &*self.logger pattern.

Also applies to: 18726-18726, 18749-18749, 18759-18759, 18775-18775


14815-14815: Confirm correct signature for create_response_for_invoice_request
Verified in lightning/src/offers/flow.rs:941–944 that the function expects &self, signer, router, invoice_request, amount_msats, … and the call passes &self.node_signer, &self.router in the proper order.


4884-4884: Logger parameter added for observability.

The addition of &*self.logger to create_recv_pending_htlc_info improves HTLC receive logging. Verify that the argument order matches the updated function signature.

lightning/src/ln/onion_payment.rs (2)

282-285: Auth enforced for blinded receive paths

Authentication is checked for both BlindedReceive and TrampolineBlindedReceive. This is the right place in the flow.

Also applies to: 316-317


248-267: UnauthenticatedPayload mapping and serialization are correct
LocalHTLCFailureReason::UnauthenticatedPayload is defined, failure_code() returns BADONION | PERM | 25, and its serialization is covered by existing tests.

fuzz/src/full_stack.rs (1)

159-162: Router signature update to accept ReceiveAuthKey — LGTM

Interface alignment only; no behavior change.

lightning/src/ln/blinded_payment_tests.rs (7)

20-20: LGTM! Import update aligns with authentication refactor.

The change from UnauthenticatedReceiveTlvs to ReceiveTlvs is consistent with the broader refactor to enforce authentication in blinded payment paths.


78-96: LGTM! Helper function properly updated for authentication.

The function correctly:

  • Constructs ReceiveTlvs with payment constraints
  • Obtains receive_auth_key from the keys manager
  • Passes the authentication key to BlindedPaymentPath::new()

163-178: LGTM! Test correctly implements authenticated blinded path.

The test properly obtains the receive_auth_key and passes it to BlindedPaymentPath::new(), consistent with the new authentication mechanism.


1454-1454: LGTM! Correct error type for authentication failure.

Changing the expected error from InvalidOnionBlinding to UnauthenticatedPayload is appropriate, as this test specifically verifies that authentication failures are properly detected and reported with the correct error type.


1626-1626: LGTM! Test implementations use appropriate fixed keys.

The TestEcdhSigner implementations return a fixed test key ReceiveAuthKey([41; 32]), which is appropriate for test mocks and provides deterministic behavior.

Also applies to: 1939-1939


1325-1340: LGTM! Test correctly updated for authenticated blinded paths.

The test follows the proper pattern of obtaining receive_auth_key from the keys manager and passing it to BlindedPaymentPath::new().


2011-2023: LGTM! Trampoline test properly integrates authentication.

The test correctly:

  • Constructs ReceiveTlvs with payment constraints
  • Obtains the receive_auth_key from the keys manager
  • Passes it with Some(receive_auth_key) to construct_blinded_hops, indicating the authentication key is optional for intermediate hops but required for the final recipient
lightning/src/routing/router.rs (5)

31-31: Import of ReceiveAuthKey looks correct

Matches the new API flow; no issues.


202-205: Plumbing ReceiveAuthKey into BlindedPaymentPath::new

Argument order and usage look consistent with the new constructor. LGTM.


214-216: Fallback path includes ReceiveAuthKey

One-hop/fallback case updated consistently. Looks good.


248-251: FixedRouter signature updated

Underscored params correctly avoid unused warnings. No concerns.


132-134: API change applied: signature updated consistently All Router::create_blinded_payment_paths implementations and invocations now include secp_ctx in the correct position.

lightning/src/blinded_path/payment.rs (9)

232-233: LGTM!

The integration of ChaChaDualPolyReadAdapter with the receive authentication key is correct and consistent with the pattern used in lightning/src/ln/msgs.rs.


509-513: Clarify backward compatibility implications.

The comment indicates that blinded payment paths created with LDK versions prior to v0.2 will fail authentication checks and cannot be used. This is a breaking change in terms of protocol compatibility.

Please confirm:

  1. This breaking change is intentional and acceptable
  2. It will be documented in release notes or migration guide
  3. There's no need to maintain backward compatibility with pre-v0.2 paths

567-570: LGTM!

The ReceiveTlvs construction correctly handles all required fields with proper error handling for missing values.


603-606: LGTM!

Consistent with BlindedPaymentTlvs::Receive construction pattern.


615-633: LGTM!

Correctly threads ReceiveAuthKey to only the payee node (line 622) while intermediate nodes receive None, which is appropriate since only the final recipient needs to authenticate and decrypt the receive TLVs.


690-742: LGTM!

The parameter type change from UnauthenticatedReceiveTlvs to ReceiveTlvs is consistent with the authentication model refactoring, and all field accesses are correct.


814-814: LGTM!

All test cases have been properly updated to use ReceiveTlvs directly with all required fields. The test coverage appears comprehensive.

Also applies to: 864-864, 882-882, 939-939, 998-998, 1067-1067


92-111: Verify breaking API change
Automated searches returned no invocations of BlindedPaymentPath::one_hop. As this is a public-API signature change requiring a new receive_auth_key argument, manually confirm that all call sites—including examples, tests, fuzz targets, and any external integrations—have been updated accordingly.


119-155: All BlindedPaymentPath::new callers updated for receive_auth_key. Router, unit tests (including max_payment_path_len_tests.rs and blinded_payment_tests.rs) and fuzz harnesses now include the new parameter.

lightning/src/offers/flow.rs (8)

26-26: LGTM!

Import change is consistent with the removal of UnauthenticatedReceiveTlvs type.


361-377: LGTM!

Test helper correctly updated to match the internal method signature.


812-867: LGTM!

The removal of entropy_source parameter is consistent with the changes in create_blinded_payment_paths.


941-1017: LGTM!

Signature changes are consistent with the broader refactoring to remove entropy_source dependencies.


1323-1345: LGTM!

Signature refactoring improves readability without changing functionality.


1398-1456: LGTM!

Signature simplification is consistent with check_refresh_async_receive_offer_cache.


1614-1661: LGTM!

Method signature updates are consistent with the broader refactoring. The logic flow correctly passes parameters through the call chain.


322-356: Confirm persistent receive_auth_key design and document rotation

  • The entropy_source parameter was removed and all callers were updated to use the persistent Flow::receive_auth_key (no remaining uses of entropy_source).
  • Please confirm this shift to a long-lived auth key is intentional, does not weaken privacy/security, and that any key-rotation strategy is documented.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lightning/src/offers/flow.rs (1)

812-867: Breaking API change: update all call sites

create_static_invoice_builder now requires usable_channels and peers. Remaining 4-argument invocations must be updated, for example in:

  • lightning/src/ln/async_payments_tests.rs:331
  • lightning/src/ln/async_payments_tests.rs:698
  • lightning/src/ln/async_payments_tests.rs:1678
♻️ Duplicate comments (4)
lightning/src/ln/blinded_payment_tests.rs (1)

1410-1416: Make mismatched ReceiveAuthKey deterministic (avoid all‑zero key)

Use a derived key with a flipped bit to guarantee mismatch instead of [0u8; 32].

Apply this diff:

-	// Use a mismatched ReceiveAuthKey to force auth failure:
-	let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);
+	// Use a guaranteed-mismatched ReceiveAuthKey to force auth failure:
+	let mut real = chanmon_cfgs[1].keys_manager.get_receive_auth_key().0;
+	real[0] ^= 0x01;
+	let mismatched_receive_auth_key = ReceiveAuthKey(real);

Also applies to: 1417-1419

lightning/src/ln/onion_payment.rs (2)

459-461: Call updated to pass logger — resolved.

decode_incoming_update_add_htlc_onion now receives logger.deref(); matches the revised signature.


500-504: create_recv_pending_htlc_info call updated with new args — resolved.

current_height and logger.deref() are passed; argument order matches the function definition.

To ensure no stale callsites remain, run:

#!/bin/bash
rg -nP 'create_recv_pending_htlc_info\s*\(' -C2
lightning/src/ln/msgs.rs (1)

2342-2342: Document payment_tlvs_authenticated semantics

Add a brief doc line clarifying it is true when payment TLVs were authenticated using ReceiveAuthKey.

 pub struct InboundOnionBlindedReceivePayload {
   pub sender_intended_htlc_amt_msat: u64,
   pub total_msat: u64,
   pub cltv_expiry_height: u32,
   pub payment_secret: PaymentSecret,
   pub payment_constraints: PaymentConstraints,
   pub payment_context: PaymentContext,
   pub intro_node_blinding_point: Option<PublicKey>,
   pub keysend_preimage: Option<PaymentPreimage>,
   pub invoice_request: Option<InvoiceRequest>,
   pub custom_tlvs: Vec<(u64, Vec<u8>)>,
+  /// True iff the payment TLVs were authenticated (AAD) using `ReceiveAuthKey`.
   pub payment_tlvs_authenticated: bool,
 }
🧹 Nitpick comments (6)
lightning/src/routing/router.rs (1)

132-134: API change: create_blinded_payment_paths now requires ReceiveAuthKey

This is a breaking change for Router consumers. Please:

  • Document migration steps (CHANGELOG/RELEASE NOTES).
  • Consider adding a convenience helper on DefaultRouter to derive a ReceiveAuthKey (from EntropySource) to ease callers.
lightning/src/ln/blinded_payment_tests.rs (2)

81-81: Optional: prefer u32::MAX over u32::max_value()

Minor modernization/readability tweak; no behavior change.

Also applies to: 166-166, 219-219


90-91: Optional: drop unnecessary mut on Secp256k1 context

Secp256k1::new() returns an immutable context; mut is not required.

Also applies to: 173-174, 201-202, 1390-1391, 1525-1526

lightning/src/ln/onion_payment.rs (1)

248-267: Auth gate and logger threading added — sound.

The new logger param and check_authentication closure are correct; returning UnauthenticatedPayload with warn log is appropriate.

Consider renaming allow_underpay to allow_skimmed_fees (or similar) for clarity.

Confirm we only require authentication for blinded receives (not for unblinded Receive/TrampolineReceive) per the intended protocol.

lightning/src/ln/msgs.rs (2)

3660-3716: ReceiveAuthKey plumbing and auth flag enforcement are correct

  • BlindedReceive now carries payment_tlvs_authenticated from used_aad, and onion_payment.rs rejects unauthenticated payloads via check_authentication.
  • NodeSigner::get_receive_auth_key is exposed in trait and impls; consider adding a ReceiveAuthKey method to replace .0 tuple access.
  • Add unit tests for InboundOnionBlindedReceivePayload decoding to assert payment_tlvs_authenticated is set/unset based on AAD usage.

3758-3864: Add tests for trampoline receive AAD handling
Verified that payment_tlvs_authenticated is correctly propagated and check_authentication is invoked for trampoline receive paths; add tests covering both authenticated and unauthenticated flows.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d64c86 and 1c3d125.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (17 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (13 hunks)
  • lightning/src/ln/channelmanager.rs (10 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (12 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (6 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, beta)
  • GitHub Check: build-tx-sync (macos-latest, stable)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (windows-latest, stable)
🔇 Additional comments (38)
lightning/src/ln/async_payments_tests.rs (1)

1861-1861: LGTM! Clean structural refactoring.

The field access path has been correctly updated to match the flattened TLV structure, removing one level of indirection. This aligns with the PR's refactoring of the authentication model for blinded payment paths.

lightning/src/ln/channelmanager.rs (5)

38-38: LGTM!

The import additions for payment context types are straightforward and align with the broader authentication key flow changes mentioned in the PR summary.


17879-17879: LGTM!

The addition of TestLogger imports and instantiation in test code is standard practice for supporting the new logger parameters in function calls.

Also applies to: 18704-18704, 18759-18759


18726-18726: LGTM!

The test code correctly passes the &logger parameter to create_recv_pending_htlc_info, consistent with the production code changes.

Also applies to: 18749-18749, 18775-18775


14815-14815: No change required for router parameter

create_response_for_invoice_request expects a router implementing Deref, so passing &self.router matches its signature.


4884-4884: All create_recv_pending_htlc_info call sites include the logger parameter
Verified every invocation now ends with the logger argument.

lightning/src/blinded_path/payment.rs (3)

218-236: LGTM! Authentication implementation looks correct.

The integration of ReceiveAuthKey for authenticating encrypted payloads follows the expected pattern. The use of ChaChaDualPolyReadAdapter with the authentication key provides cryptographic verification of the payload.


119-155: Verified: all BlindedPaymentPath::new callers now include the new receive_auth_key parameter.


92-111: Breaking API change: added receive_auth_key parameter
Confirm all callers of BlindedPaymentPath::one_hop have been updated; a search for usage (rg -nP --type=rust '\bone_hop\s*\(') returned no matches, so please manually verify any call sites.

lightning/src/offers/flow.rs (5)

322-356: LGTM! Consistent parameter threading.

The function correctly threads receive_auth_key through to the router's create_blinded_payment_paths and properly constructs ReceiveTlvs with payment constraints.


1398-1456: LGTM! Well-structured implementation.

The function correctly handles invoice refresh by:

  • Iterating over offers needing updates
  • Continuing on errors rather than failing entirely
  • Avoiding lock contention by enqueueing messages in a separate loop

1614-1661: LGTM! Proper parameter integration.

The function correctly integrates the new usable_channels parameter for creating blinded payment paths in the static invoice.


941-1017: Internal call sites updated; no other usages found.
The only invocation in lightning/src/ln/channelmanager.rs has been adjusted for the new router and usable_channels parameters.


1323-1345: No breaking external API. The added parameters to Flow::check_refresh_async_receive_offer_cache are fully encapsulated by ChannelManager’s unchanged public method, so callers need no updates.

Likely an incorrect or invalid review comment.

lightning/src/routing/router.rs (4)

31-31: LGTM: new import is used

ReceiveAuthKey is correctly imported and used; no dead code.


183-185: Good fix: use saturating_add to avoid overflow

This restores safe behavior for max_cltv_expiry adjustment.


202-202: Confirm ReceiveAuthKey reuse semantics across paths

You pass the same receive_auth_key into each BlindedPaymentPath::new. Confirm this key must be constant per invoice/recipient (not per path). If per‑path keys are desired, derive subkeys deterministically (e.g., HKDF with path index).

Also applies to: 214-214


248-251: LGTM: FixedRouter signature updated

Param is intentionally unused; consistent with this router’s purpose.

fuzz/src/chanmon_consistency.rs (1)

130-137: LGTM: Router trait signature updated correctly.

The create_blinded_payment_paths signature now includes the _receive_auth_key: ReceiveAuthKey parameter and uses ReceiveTlvs, aligning with the new authenticated payment path construction flow.

lightning/src/ln/max_payment_path_len_tests.rs (1)

215-235: LGTM: Test correctly migrated to new authentication model.

The test now:

  1. Directly constructs ReceiveTlvs (line 215-222)
  2. Obtains receive_auth_key from the keys manager (line 223)
  3. Passes receive_auth_key to BlindedPaymentPath::new (line 228)

This eliminates the previous nonce-based HMAC authentication step, simplifying the flow.

fuzz/src/invoice_request_deser.rs (1)

86-143: LGTM: Fuzz test migrated to simplified authentication flow.

Key changes:

  1. Hardcoded ReceiveAuthKey([41; 32]) is appropriate for fuzz testing (line 86)
  2. Direct ReceiveTlvs construction without intermediate authentication (lines 108-115)
  3. Direct field access payee_tlvs.payment_constraints indicates flatter TLV structure (line 125)
  4. receive_auth_key threaded through to BlindedPaymentPath::new (line 137)
fuzz/src/full_stack.rs (1)

159-162: LGTM: Consistent Router trait signature update.

The signature matches the changes in other fuzz files, properly adding _receive_auth_key: ReceiveAuthKey and updating _tlvs to ReceiveTlvs.

fuzz/src/refund_deser.rs (1)

71-108: LGTM: Consistent fuzz test migration.

This follows the same pattern as invoice_request_deser.rs:

  • Hardcoded ReceiveAuthKey for testing (line 71)
  • Direct ReceiveTlvs construction (lines 73-80)
  • Direct field access payee_tlvs.payment_constraints (line 90)
  • receive_auth_key passed to path construction (line 102)
lightning/src/offers/signer.rs (1)

43-50: LGTM: HMAC constants properly reserved to prevent type confusion.

The removal of PAYMENT_TLVS_HMAC_INPUT and related functions aligns with the migration to ReceiveAuthKey-based authentication. Reserving the values [5; 16], [7; 16], and [8; 16] is a good security practice to prevent type confusion attacks if these constants are inadvertently reused.

lightning/src/ln/blinded_payment_tests.rs (10)

20-20: Import updates look correct

Switched to ReceiveTlvs and related symbols. LGTM.


78-86: Correctly thread ReceiveAuthKey and ReceiveTlvs into path construction

Good migration: build ReceiveTlvs, fetch receive_auth_key, and pass both to BlindedPaymentPath::new. LGTM.

Also applies to: 88-95


163-171: One-hop path: auth key and ReceiveTlvs usage is sound

BlindedPaymentPath::new invocation matches new API. LGTM.

Also applies to: 175-177


216-224: MPP to one-hop: new authentication flow integrated

ReceiveTlvs + receive_auth_key passed correctly. LGTM.

Also applies to: 226-228


1325-1334: Custom TLVs flow: updated ReceiveTlvs/auth key wiring

Construction and usage align with new API. LGTM.

Also applies to: 1334-1334, 1337-1339


1379-1387: Auth success case: updated ReceiveTlvs/auth key wiring

Matches expectations before forced failure. LGTM.

Also applies to: 1391-1394


1454-1455: Updated expected error aligns with new unauthenticated payload semantics

Expecting UnauthenticatedPayload with empty data is correct here. LGTM.


1627-1627: Test signer: get_receive_auth_key stub is fine

Static key for tests is acceptable. LGTM.


1939-1939: Inbound decoding test: get_receive_auth_key stub is fine

Consistent with above. LGTM.


2011-2024: Trampoline single-hop receive: authenticated ReceiveTlvs path

Encoding ReceiveTlvs and passing receive_auth_key into blinded hops looks correct. LGTM.

lightning/src/util/test_utils.rs (1)

291-294: Router::create_blinded_payment_paths signature update handled correctly

New receive_auth_key parameter added and forwarded to inner router; fallbacks preserved. LGTM.

Also applies to: 297-305

lightning/src/ln/onion_payment.rs (1)

283-285: Authentication enforced for blinded receive paths — LGTM.

The early check prevents unauthenticated blinded payments from proceeding.

Also applies to: 316-317

lightning/src/ln/msgs.rs (2)

35-35: LGTM: import ReceiveTlvs

Required for the new decode path. No concerns.


59-59: LGTM: import ChaChaDualPolyReadAdapter

Matches the new authenticated-TLV decode flow.

Comment on lines +509 to +513
// Note: Authentication TLV field was removed in LDK v0.2 following the
// introduction of `ReceiveAuthKey`-based authentication for inbound
// `BlindedPaymentPaths`s. Because we do not support receiving to those
// contexts anymore (they will fail the `ReceiveAuthKey`-based
// authentication checks), we can reuse those fields here.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify backward compatibility implications.

The comment indicates that TLV fields previously used for authentication are being reused, and old contexts will fail the new ReceiveAuthKey-based authentication. This appears to be an intentional breaking change.

Please confirm:

  1. This breaking change is documented in migration/upgrade notes
  2. The version compatibility matrix is updated
  3. There are no supported upgrade paths from versions using the old authentication TLV fields

You may want to search documentation for mentions of this breaking change:


🏁 Script executed:

#!/bin/bash
# Description: Search for documentation of the authentication change

fd -e md -e txt | xargs rg -l "ReceiveAuthKey|authentication.*TLV|v0\.2" 

Length of output: 383


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' pending_changelog/3917-blinded-path-auth.txt

Length of output: 103


🏁 Script executed:

#!/bin/bash
# Search for compatibility matrix in documentation
fd -e md -e txt | xargs rg -n 'compatibil'
# Search for migration or upgrade guides
fd -e md -e txt | xargs rg -n 'migration|upgrade'

Length of output: 2270


Document blinded-path auth breaking change and upgrade guidance.

  • Mirror “invalidates existing Refunds containing blinded paths” under v0.2.0 in CHANGELOG.md.
  • Add an upgrade/migration section (e.g. docs/UPGRADE.md) clarifying removal of the TLV auth field and lack of rollback path.
  • Update the compatibility matrix to flag this breaking change for v0.2.0.
🤖 Prompt for AI Agents
In lightning/src/blinded_path/payment.rs around lines 509 to 513, add
documentation and upgrade guidance for the LDK v0.2 breaking change: update
CHANGELOG.md to mirror the note that v0.2.0 invalidates existing Refunds
containing blinded paths, add a new section in docs/UPGRADE.md explaining
removal of the TLV authentication field, the ReceiveAuthKey-based authentication
change, and that there is no rollback path (include recommended migration steps
for operators), and update the compatibility matrix (e.g., docs/COMPATIBILITY.md
or README) to mark v0.2.0 as a breaking change for blinded-path auth; ensure the
messages are concise and reference this file/lines for context.

@shaavan shaavan force-pushed the aad-payment-review branch from 1c3d125 to 2980c17 Compare October 6, 2025 17:55
Extends the work started in
[PR#3917](lightningdevkit#3917)
by adding ReceiveAuthKey-based verification for Blinded Payment Paths.

This reduces space previously taken by individual ReceiveTlvs and
aligns the verification logic with that used for Blinded Message Paths.
Now that we have introduced an alternate mechanism for authentication
in the codebase, we can safely remove the now redundant (hmac, nonce)
fields from the Payment ReceiveTlvs's while maintaining the security
of the onion messages.
@shaavan shaavan force-pushed the aad-payment-review branch from 2980c17 to cf551f6 Compare October 6, 2025 18:07
@shaavan
Copy link
Owner Author

shaavan commented Oct 6, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Oct 6, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lightning/src/ln/msgs.rs (1)

3664-3683: Rejecting blinded forwards on authenticated TLVs breaks valid flows

ChaChaDualPolyReadAdapter::read sets used_aad whenever the sender authenticated a TLV with the receive auth key. For forwards that is legitimate: intermediate hops will never use the auth key, but the sender could still mark the TLVs as authenticated. The new if … || used_aad { return Err(DecodeError::InvalidValue) } rejects those packets outright, which means any authenticated blinded forward now fails to decode. The auth bit should only gate final-hop variants, not BlindedPaymentTlvs::Forward.

Please drop the || used_aad guard (or rework it so forwards ignore the flag) to restore compatibility with valid authenticated forward payloads while keeping the receive case check.

♻️ Duplicate comments (2)
lightning/src/ln/onion_utils.rs (1)

1769-1773: Treat UnauthenticatedPayload as a recipient failure

UnauthenticatedPayload bubbles all the way up as an intermediate-hop error because is_recipient_failure() still returns false. That causes the router to penalize the previous public channel instead of marking the payment as a final-hop failure, undoing the intended scoring fix. Please include the new variant in the recipient check.

 		self.failure_code() == LocalHTLCFailureReason::IncorrectPaymentDetails.failure_code()
 			|| *self == LocalHTLCFailureReason::FinalIncorrectCLTVExpiry
 			|| *self == LocalHTLCFailureReason::FinalIncorrectHTLCAmount
 			|| *self == LocalHTLCFailureReason::MPPTimeout
+			|| *self == LocalHTLCFailureReason::UnauthenticatedPayload
lightning/src/ln/blinded_payment_tests.rs (1)

1417-1418: Unsafe mismatched key construction—use bit-flip instead of zeros.

Using ReceiveAuthKey([0u8; 32]) as the mismatched key is unsafe because if the real key ever returns zeros, the test would incorrectly pass (the keys would match). To guarantee a mismatch, flip a bit of the real key instead.

Apply this diff to ensure a guaranteed mismatch:

-// Use a mismatched ReceiveAuthKey to force auth failure:
-let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);
+// Use a guaranteed-mismatched ReceiveAuthKey to force auth failure:
+let mut real = chanmon_cfgs[1].keys_manager.get_receive_auth_key().0;
+real[0] ^= 0x01;
+let mismatched_receive_auth_key = ReceiveAuthKey(real);

Based on past review comments.

🧹 Nitpick comments (3)
lightning/src/ln/max_payment_path_len_tests.rs (1)

224-234: Minor nit: unnecessary mut on secp_ctx

secp_ctx isn’t mutated. You can drop mut for clarity.

- let mut secp_ctx = Secp256k1::new();
+ let secp_ctx = Secp256k1::new();
fuzz/src/invoice_request_deser.rs (1)

125-126: Use saturating_add to avoid overflow under fuzzing

Payee constraint math can overflow u32 in edge cases. Prefer saturating_add.

-                max_cltv_expiry: payee_tlvs.payment_constraints.max_cltv_expiry + 40,
+                max_cltv_expiry: payee_tlvs.payment_constraints
+                    .max_cltv_expiry
+                    .saturating_add(40),
lightning/src/routing/router.rs (1)

287-292: Public trait break acknowledged; docs updated

Doc comment clarifies receive_auth_key requirement. Consider also:

  • Add CHANGELOG entry and brief migration guide note.
  • Optional: accept &ReceiveAuthKey to avoid copying sensitive material (if the type is non-trivial).

Please confirm a CHANGELOG/migration note exists for the added parameter and param reordering.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c3d125 and cf551f6.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (17 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (12 hunks)
  • lightning/src/ln/channelmanager.rs (10 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (12 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (4 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • fuzz/src/chanmon_consistency.rs
  • lightning/src/offers/flow.rs
🧰 Additional context used
🧬 Code graph analysis (7)
lightning/src/ln/channelmanager.rs (1)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/ln/blinded_payment_tests.rs (4)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/offers/flow.rs (1)
  • get_receive_auth_key (192-194)
lightning/src/util/test_utils.rs (2)
  • get_receive_auth_key (1730-1732)
  • get_receive_auth_key (1822-1824)
lightning/src/sign/mod.rs (3)
  • get_receive_auth_key (880-880)
  • get_receive_auth_key (2220-2222)
  • get_receive_auth_key (2393-2395)
lightning/src/routing/router.rs (4)
lightning/src/offers/flow.rs (1)
  • create_blinded_payment_paths (322-356)
fuzz/src/chanmon_consistency.rs (1)
  • create_blinded_payment_paths (130-136)
fuzz/src/full_stack.rs (1)
  • create_blinded_payment_paths (158-164)
lightning/src/util/test_utils.rs (1)
  • create_blinded_payment_paths (290-308)
lightning/src/ln/msgs.rs (1)
lightning/src/ln/channelmanager.rs (2)
  • new (3847-3925)
  • new (16114-16135)
lightning/src/ln/max_payment_path_len_tests.rs (3)
lightning/src/blinded_path/payment.rs (1)
  • new (119-155)
lightning/src/ln/channelmanager.rs (2)
  • new (3847-3925)
  • new (16114-16135)
lightning/src/offers/flow.rs (1)
  • new (118-149)
lightning/src/util/test_utils.rs (1)
lightning/src/routing/router.rs (14)
  • first_hops (156-207)
  • first_hops (7886-7886)
  • first_hops (7910-7910)
  • first_hops (8313-8313)
  • first_hops (8323-8323)
  • first_hops (8382-8382)
  • first_hops (8542-8542)
  • first_hops (8622-8622)
  • first_hops (8687-8687)
  • first_hops (8741-8741)
  • first_hops (8861-8861)
  • first_hops (8877-8877)
  • first_hops (8889-8889)
  • first_hops (9033-9033)
lightning/src/blinded_path/payment.rs (3)
lightning/src/ln/channelmanager.rs (13)
  • new (3847-3925)
  • new (16114-16135)
  • read (612-615)
  • read (662-665)
  • read (1250-1264)
  • read (1497-1499)
  • read (15355-15396)
  • read (15447-15492)
  • read (15497-15544)
  • read (15626-15659)
  • read (15949-15965)
  • read (16164-16170)
  • node (19057-19057)
lightning/src/ln/msgs.rs (8)
  • new (2509-2511)
  • new (2544-2546)
  • read (1147-1171)
  • read (1175-1181)
  • read (3344-3355)
  • read (3404-3408)
  • read (3591-3749)
  • read (3756-3898)
lightning/src/blinded_path/message.rs (3)
  • new (68-85)
  • blinded_hops (171-173)
  • blinded_hops (693-733)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: linting
  • GitHub Check: check_release
  • GitHub Check: benchmark
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: benchmark
  • GitHub Check: build-tx-sync (macos-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, 1.75.0)
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build-tx-sync (ubuntu-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, beta)
  • GitHub Check: build-tx-sync (ubuntu-latest, beta)
  • GitHub Check: linting
  • GitHub Check: check_release
  • GitHub Check: semver-checks
  • GitHub Check: semver-checks
🔇 Additional comments (24)
lightning/src/ln/channelmanager.rs (4)

38-38: LGTM: Import addition aligns with PR objectives.

The addition of payment context imports (AsyncBolt12OfferContext, Bolt12OfferContext, PaymentContext) is consistent with the PR's goal of adding ReceiveAuthKey verification for blinded payment paths. While the visible hunks don't show the usage of these types, this is expected as we're only seeing fragments of the changes.


4884-4884: LGTM: Logger parameter additions are consistent.

The addition of &*self.logger as the final parameter to create_recv_pending_htlc_info is applied consistently across call sites. This pattern correctly dereferences and borrows the logger, which is appropriate for Rust trait object parameters.

Also applies to: 6995-6995


14815-14815: LGTM: Parameter update aligns with authentication flow changes.

The addition of &self.node_signer and &self.router parameters to create_response_for_invoice_request is consistent with the PR's objective to thread ReceiveAuthKey through the payment flow. The parameters are correctly borrowed.


17879-17879: LGTM: Test code updates are consistent and correct.

The test code has been updated systematically to:

  1. Import TestLogger from test utilities
  2. Instantiate TestLogger::new() in test functions
  3. Pass &logger to create_recv_pending_htlc_info calls

All changes follow the same pattern and correctly match the updated function signatures in the production code.

Also applies to: 18704-18704, 18726-18726, 18749-18749, 18759-18759, 18775-18775

lightning/src/ln/async_payments_tests.rs (1)

1861-1863: TLV access update looks correct

Switching to tlvs.payment_constraints.max_cltv_expiry matches the new ReceiveTlvs layout. LGTM.

lightning/src/util/test_utils.rs (1)

291-305: Router API update threaded cleanly

Added receive_auth_key param and forwarded to inner router correctly. No issues spotted.

lightning/src/offers/signer.rs (1)

43-51: Reserved HMAC inputs comment sync

Reservation notes (including [8;16]) are clear and prevent reuse. LGTM.

lightning/src/ln/max_payment_path_len_tests.rs (2)

15-16: Import migration to ReceiveTlvs

Updated import aligns with new API. OK.


215-223: ReceiveTlvs construction matches new type

Fields populated correctly, consistent with router usage. OK.

fuzz/src/invoice_request_deser.rs (1)

135-143: BlindedPaymentPath::new updated usage looks good

Passing receive_auth_key and ReceiveTlvs matches the new constructor. OK.

fuzz/src/full_stack.rs (1)

158-164: LGTM! Fuzz stub updated correctly.

The create_blinded_payment_paths signature has been updated to include the new _receive_auth_key: ReceiveAuthKey parameter. The method correctly returns unreachable!() as expected for a fuzz test stub.

fuzz/src/refund_deser.rs (1)

71-109: LGTM! Clean migration to ReceiveTlvs and ReceiveAuthKey.

The code has been cleanly migrated from the old authentication flow:

  • ReceiveTlvs is now constructed directly instead of UnauthenticatedReceiveTlvs followed by authentication
  • A ReceiveAuthKey([41; 32]) is consistently used (matching test utilities elsewhere)
  • The receive_auth_key is properly threaded through to BlindedPaymentPath::new

The simplification from payee_tlvs.tlvs().payment_constraints to payee_tlvs.payment_constraints correctly reflects the updated type structure.

lightning/src/ln/blinded_payment_tests.rs (6)

47-96: LGTM! Helper function updated correctly.

The blinded_payment_path helper has been properly updated to:

  • Use ReceiveTlvs instead of the old unauthenticated variant
  • Retrieve receive_auth_key from the keys manager
  • Thread the key through to BlindedPaymentPath::new

154-193: LGTM! Test updated correctly.

The one_hop_blinded_path test has been cleanly updated to use ReceiveTlvs and retrieve the receive_auth_key from the keys manager before passing it to path construction.


196-272: LGTM! MPP test updated correctly.

The multi-path payment test has been properly updated to use the new authentication key flow.


1315-1367: LGTM! Custom TLVs test updated correctly.

The test correctly constructs ReceiveTlvs, retrieves the authentication key, and threads it through path construction.


1626-1626: LGTM! Test signer implementations updated correctly.

Both TestEcdhSigner implementations correctly provide get_receive_auth_key() returning a consistent test key ReceiveAuthKey([41; 32]), which aligns with test utilities elsewhere in the codebase.

Also applies to: 1939-1939


2011-2026: LGTM! Trampoline test updated correctly.

The test properly constructs ReceiveTlvs and threads the receive_auth_key through the blinded hop construction. The pattern of passing Some(receive_auth_key) in the tuple is consistent with the new API for authenticated receive hops.

lightning/src/routing/router.rs (6)

31-31: Import of ReceiveAuthKey looks correct

New dependency is cleanly introduced; no issues.


183-185: Good: avoid overflow with saturating_add

Prevents CLTV overflow while preserving candidate paths.


202-204: Pass-through of receive_auth_key to BlindedPaymentPath::new is correct

Ordering matches the updated constructor; no issues spotted.


214-216: Fallback path: receive_auth_key plumbed correctly

Consistent with the multi-hop path case.


248-251: FixedRouter signature updated appropriately

Underscored args avoid warnings; behavior unchanged.


132-134: Approve: signature change applied – callers updated
Add a migration note documenting the ReceiveAuthKey parameter addition and reordering.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (9)
lightning/src/ln/onion_utils.rs (2)

1768-1773: UnauthenticatedPayload must be classified as recipient failure.

UnauthenticatedPayload is a final-hop error indicating the recipient cannot authenticate the payment TLVs, yet it is omitted from is_recipient_failure(). This causes the error to be misclassified as an intermediate-hop failure, leading to incorrect pathfinding penalties against the last public hop instead of the actual recipient.

Apply this diff to fix the classification:

 fn is_recipient_failure(&self) -> bool {
     self.failure_code() == LocalHTLCFailureReason::IncorrectPaymentDetails.failure_code()
         || *self == LocalHTLCFailureReason::FinalIncorrectCLTVExpiry
         || *self == LocalHTLCFailureReason::FinalIncorrectHTLCAmount
         || *self == LocalHTLCFailureReason::MPPTimeout
+        || *self == LocalHTLCFailureReason::UnauthenticatedPayload
 }

Note: This issue was previously flagged in an earlier review but the fix was not applied.


1730-1730: Verify interoperability of custom failure code.

UnauthenticatedPayload uses BADONION | PERM | 24, which is not defined in BOLT #4. According to previous review research, using ad-hoc failure codes breaks interoperability with other Lightning implementations. Consider either:

  1. Mapping to an existing BOLT #4 code that approximates this error condition
  2. Submitting a BOLT proposal to add a standardized code for unauthenticated payloads
  3. Documenting the interoperability implications if proceeding with the custom code
What is the current status of BOLT proposals for adding an "unauthenticated payload" failure code to BOLT #4?
lightning/src/ln/msgs.rs (1)

2342-2343: Document payment_tlvs_authenticated.

Please add the brief /// doc string clarifying that this flag is set when the blinded payment TLVs were authenticated with the ReceiveAuthKey. That context is still missing here as previously requested.

lightning/src/blinded_path/payment.rs (2)

232-235: DUPLICATE: Missing used_aad validation allows unauthenticated payloads.

This critical issue was already flagged in a previous review. The used_aad flag from ChaChaDualPolyReadAdapter is not checked, so legacy payloads without the Poly1305 authentication tag will still decrypt successfully, bypassing the new ReceiveAuthKey-based authentication mechanism.


509-513: DUPLICATE: Document the breaking change and provide upgrade guidance.

This issue was already flagged in a previous review. The comment indicates that TLV fields are being reused and old contexts will fail authentication, but this breaking change needs to be properly documented in CHANGELOG.md, migration guides, and the compatibility matrix.

lightning/src/ln/blinded_payment_tests.rs (1)

1417-1418: Make mismatched key derivation robust.

As flagged in a previous review, using ReceiveAuthKey([0; 32]) is fragile. Derive the mismatched key by flipping a bit of the real key to guarantee inequality and make the test self-documenting.

-// Use a mismatched ReceiveAuthKey to force auth failure:
-let mismatched_receive_auth_key = ReceiveAuthKey([0u8; 32]);
+// Use a guaranteed-mismatched ReceiveAuthKey to force auth failure:
+let mut real = chanmon_cfgs[1].keys_manager.get_receive_auth_key().0;
+real[0] ^= 0x01;
+let mismatched_receive_auth_key = ReceiveAuthKey(real);
lightning/src/routing/router.rs (3)

132-134: DefaultRouter::create_blinded_payment_paths signature updated — OK

Param order matches trait; type bounds intact.


183-185: Correctly avoid CLTV overflow with saturating_add

Prevents u32 wrap/drop; resolves prior risk.


287-293: Router trait: added receive_auth_key and updated docs — OK

Signature and doc align; breaking change acknowledged elsewhere.

🧹 Nitpick comments (3)
lightning/src/ln/max_payment_path_len_tests.rs (1)

215-234: Good migration to ReceiveTlvs + ReceiveAuthKey; tiny cleanup

  • Constructing ReceiveTlvs and passing receive_auth_key into BlindedPaymentPath::new aligns with the new API. LGTM.
  • Minor: secp_ctx doesn’t need to be mutable.

Apply this cleanup:

- let mut secp_ctx = Secp256k1::new();
+ let secp_ctx = Secp256k1::new();
fuzz/src/invoice_request_deser.rs (1)

86-116: Fuzz updated to ReceiveTlvs + ReceiveAuthKey — OK; optional realism

  • Swapping to ReceiveTlvs and threading receive_auth_key into BlindedPaymentPath::new is correct. LGTM.
  • Optional: Instead of a hard-coded ReceiveAuthKey([41; 32]), consider obtaining it via a NodeSigner impl to mirror prod flow (if convenient in fuzz).

Also applies to: 126-145

fuzz/src/refund_deser.rs (1)

71-81: Correct ReceiveAuthKey threading in refund fuzz

Switch to ReceiveTlvs and passing receive_auth_key into BlindedPaymentPath::new looks good. Optionally derive the key via NodeSigner for parity with production code if desired.

Also applies to: 90-109

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d64c86 and cf551f6.

📒 Files selected for processing (16)
  • fuzz/src/chanmon_consistency.rs (1 hunks)
  • fuzz/src/full_stack.rs (1 hunks)
  • fuzz/src/invoice_request_deser.rs (5 hunks)
  • fuzz/src/refund_deser.rs (4 hunks)
  • lightning/src/blinded_path/payment.rs (17 hunks)
  • lightning/src/ln/async_payments_tests.rs (1 hunks)
  • lightning/src/ln/blinded_payment_tests.rs (12 hunks)
  • lightning/src/ln/channelmanager.rs (10 hunks)
  • lightning/src/ln/max_payment_path_len_tests.rs (2 hunks)
  • lightning/src/ln/msgs.rs (12 hunks)
  • lightning/src/ln/onion_payment.rs (5 hunks)
  • lightning/src/ln/onion_utils.rs (4 hunks)
  • lightning/src/offers/flow.rs (10 hunks)
  • lightning/src/offers/signer.rs (1 hunks)
  • lightning/src/routing/router.rs (7 hunks)
  • lightning/src/util/test_utils.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build-tx-sync (macos-latest, beta)
  • GitHub Check: build-tx-sync (ubuntu-latest, 1.75.0)
  • GitHub Check: build-tx-sync (macos-latest, stable)
  • GitHub Check: benchmark
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (macos-latest, 1.63.0)
  • GitHub Check: benchmark
🔇 Additional comments (21)
lightning/src/ln/onion_utils.rs (1)

1683-1689: Enum variant and serialization implemented correctly.

The UnauthenticatedPayload variant is properly integrated into the enum definition, serialization mappings, and debug assertions. The 32-byte error data requirement (matching InvalidOnionBlinding) is appropriate for this BADONION-flagged error.

Also applies to: 1890-1891, 2052-2052

lightning/src/ln/onion_payment.rs (3)

248-255: Generic logger parameter enables flexible logging context.

The refactor to make create_recv_pending_htlc_info generic over L: Deref where L::Target: Logger allows this function to accept various logger types while maintaining compile-time dispatch. This is a clean approach for threading logging context through the payment processing pipeline.


256-266: Authentication guard correctly fails fast.

The check_authentication closure properly validates payment_tlvs_authenticated and returns UnauthenticatedPayload error before expensive constraint validation. The guard is correctly applied to both BlindedReceive and TrampolineBlindedReceive branches, ensuring consistent authentication enforcement across all blinded payment paths.

The early-exit pattern here prevents wasted processing on unauthenticated payloads and provides clear error semantics to the caller.

Also applies to: 282-284, 313-316


460-461: Logger dereferencing applied correctly at callsites.

Both decode_incoming_update_add_htlc_onion (line 460) and create_recv_pending_htlc_info (line 503) correctly pass logger.deref() to satisfy the generic logger parameter constraint. The Deref trait is properly utilized to convert from L: Deref to L::Target: Logger.

Also applies to: 503-504

lightning/src/ln/channelmanager.rs (2)

38-38: LGTM! Import changes support parameter threading.

The added imports for PaymentContext types and explicit TestLogger import align with the function signature changes throughout the file.

Also applies to: 17879-17879


18704-18704: LGTM! Test code simplified with explicit import.

The usage of TestLogger::new() instead of test_utils::TestLogger::new() is cleaner and follows from the explicit import in line 17879.

Also applies to: 18759-18759

lightning/src/blinded_path/payment.rs (2)

92-110: LGTM: ReceiveAuthKey threaded through path construction.

The addition of the receive_auth_key parameter to one_hop and new methods correctly threads the authentication key through the blinded payment path construction. The parameter is properly passed to compute_payinfo and blinded_hops.

Also applies to: 119-155


617-633: LGTM: Receive auth key correctly attached to final hop.

The blinded_hops function correctly chains the local_node_receive_key only with the payee node (line 622), ensuring the authentication key is only applied to the final receiving hop as intended.

lightning/src/offers/flow.rs (2)

322-356: LGTM: Blinded payment path creation updated correctly.

The create_blinded_payment_paths method (and its test variant) correctly:

  • Retrieves receive_auth_key from self.receive_auth_key (line 331)
  • Constructs ReceiveTlvs with all required fields (lines 342-346)
  • Passes the auth key to the router's create_blinded_payment_paths method (line 350)

Also applies to: 361-377


812-867: LGTM: Consistent use of ReceiveAuthKey across offer and invoice methods.

All methods that create blinded payment paths (create_static_invoice_builder, create_response_for_invoice_request, async payment methods) consistently:

  • Use ReceiveTlvs instead of the deprecated UnauthenticatedReceiveTlvs
  • Thread receive_auth_key through to the router
  • Construct payment contexts correctly

Also applies to: 941-1017, 1323-1345, 1398-1456, 1614-1661

fuzz/src/chanmon_consistency.rs (1)

130-136: LGTM: FuzzRouter signature updated to match Router trait.

The create_blinded_payment_paths signature correctly adds the _receive_auth_key: ReceiveAuthKey parameter and updates _tlvs to use ReceiveTlvs, matching the updated Router trait definition. Since this is a fuzzing stub that calls unreachable!(), no implementation changes are needed.

lightning/src/ln/async_payments_tests.rs (1)

1861-1863: Updated TLV access path looks correct

Using tlvs.payment_constraints.max_cltv_expiry matches the new ReceiveTlvs shape. LGTM.

lightning/src/util/test_utils.rs (1)

290-304: Router shim correctly forwards new receive_auth_key parameter

Signature and forwarding to self.router.create_blinded_payment_paths(...) match the updated trait/API. LGTM.

fuzz/src/full_stack.rs (1)

158-165: LGTM!

The updated signature correctly threads ReceiveAuthKey through the Router trait for fuzzing. The stub appropriately calls unreachable!() as this code path should not execute in fuzzing scenarios.

lightning/src/ln/blinded_payment_tests.rs (3)

78-96: LGTM!

The migration from UnauthenticatedReceiveTlvs to ReceiveTlvs and integration of ReceiveAuthKey is implemented correctly. The authentication key is properly retrieved from the keys manager and threaded through the path construction.


163-178: LGTM!

Test correctly updated to use the new authentication mechanism with ReceiveTlvs and ReceiveAuthKey.


1325-1340: LGTM!

Test updates consistently apply the new authentication mechanism across multiple test cases. The migration from UnauthenticatedReceiveTlvs to ReceiveTlvs with proper ReceiveAuthKey handling is correctly implemented.

Also applies to: 1379-1394, 2011-2026

lightning/src/routing/router.rs (4)

31-31: Import of ReceiveAuthKey looks correct

Used in new signatures; no issues.


202-205: Propagating receive_auth_key to BlindedPaymentPath::new

Threading the key through path construction looks correct.


214-216: Fallback one-hop path uses receive_auth_key — OK

Consistent with above call.


248-251: FixedRouter signature updated — OK

Unused params properly underscored; debug_assert + Err keeps release safe.

create_recv_pending_htlc_info(decoded_hop, shared_secret, msg.payment_hash,
msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
current_height)
current_height, &*self.logger)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

LGTM! Parameter threading is consistent.

The addition of logger parameters to create_recv_pending_htlc_info and signer/router parameters to create_response_for_invoice_request is applied consistently across all visible call sites.

To ensure all call sites have been updated, run the following verification script:

Also applies to: 6995-6995, 14815-14815, 18726-18726, 18749-18749, 18775-18775


🏁 Script executed:

#!/bin/bash
# Description: Verify all call sites of modified functions have been updated with new parameters.

echo "=== Checking create_recv_pending_htlc_info call sites ==="
# Search for calls without the logger parameter (old signature)
# Expected: no matches with old signature pattern
rg -n "create_recv_pending_htlc_info\(" --type rust -A 2 | rg -v "&.*logger"

echo ""
echo "=== Checking create_response_for_invoice_request call sites ==="
# Search for calls to verify all include node_signer and router
rg -n "create_response_for_invoice_request\(" --type rust -C 2

Length of output: 2079


Add missing logger argument to create_recv_pending_htlc_info calls
Several call sites still use the old signature; update them to include the new logger parameter:

  • lightning/src/ln/onion_payment.rs:500–502
  • lightning/src/ln/channelmanager.rs:4882–4884
  • lightning/src/ln/channelmanager.rs:6985–6987
  • lightning/src/ln/channelmanager.rs:18724–18726
  • lightning/src/ln/channelmanager.rs:18747–18748
  • lightning/src/ln/channelmanager.rs:18762–18764

Ensure production code passes &*self.logger and tests pass &logger.

🤖 Prompt for AI Agents
In lightning/src/ln/channelmanager.rs around line 4884 (and also update the
other listed call sites: lightning/src/ln/onion_payment.rs:500–502,
lightning/src/ln/channelmanager.rs:4882–4884, 6985–6987, 18724–18726,
18747–18748, 18762–18764), the calls to create_recv_pending_htlc_info are
missing the new logger parameter; fix each call by appending the logger argument
— in production code pass &*self.logger and in unit/test code pass &logger — so
every create_recv_pending_htlc_info invocation has the additional logger
parameter and compiles/tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant