Skip to content

Conversation

valentinewallace
Copy link
Contributor

Some cleanups in preparation for implementing sending payments as an often-offline sender to an often-offline recipient.

cc #2298

This method was rustfmt'd in the previous commit, here we clean up that
formatting.
This method will be edited in upcoming commits, and the codebase policy is to
at least consider removing rustfmt::skips when touching a method.
This method will be edited in upcoming commits, and the codebase policy is to
at least consider removing rustfmt::skips when touching a method.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Sep 2, 2025

I've assigned @joostjager as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Copy link

codecov bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 93.51852% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.77%. Comparing base (5b6b691) to head (408001c).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/outbound_payment.rs 91.01% 8 Missing ⚠️
lightning/src/ln/channelmanager.rs 94.44% 5 Missing ⚠️
lightning-dns-resolver/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4044      +/-   ##
==========================================
+ Coverage   88.73%   88.77%   +0.04%     
==========================================
  Files         176      176              
  Lines      129042   129310     +268     
  Branches   129042   129310     +268     
==========================================
+ Hits       114501   114794     +293     
+ Misses      11939    11910      -29     
- Partials     2602     2606       +4     
Flag Coverage Δ
fuzzing 22.04% <27.01%> (+0.12%) ⬆️
tests 88.60% <93.51%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

In upcoming commits, we will be adding several more conversions from
PendingAddHTLCInfo into HTLCPreviousHopData. This conversion gets repeated all
over the ChannelManager already, so lay some groundwork by DRYing it up.
@valentinewallace valentinewallace force-pushed the 2025-09-async-send-prefactor branch from ecab2b9 to ef8bec7 Compare September 2, 2025 17:30
Without this DRYing, we would be repeating the same code to instantiate the
PendingAddHTLCInfo several more times in this method, in upcoming commits.
@valentinewallace valentinewallace force-pushed the 2025-09-async-send-prefactor branch 2 times, most recently from a1bbef7 to dfbf3ae Compare September 2, 2025 21:08
The LDK codebase in general is comfortable panicking if the entropy source
provided to it is dysfunctional. Up until now we made an exception for blinded
path creation, where we would handle an error that could occur on mul_tweak
that could only occur if the session_priv provided was not actually random.
In comparable cases in onion_utils, we would panic instead.

In upcoming commits, we will be including blinded paths in outbound
revoke_and_ack messages as part of implementing async payments, where it is
difficult to handle failing back an HTLC if blinded path creation fails. Thus
we now have an incentive to make the blinded path creation methods infallible,
so do so here.
@valentinewallace valentinewallace force-pushed the 2025-09-async-send-prefactor branch from dfbf3ae to 408001c Compare September 2, 2025 21:22
});

if let PendingHTLCRouting::Forward { short_channel_id, .. } = payment.forward_info.routing {
let htlc_source = HTLCSource::PreviousHopData(payment.htlc_previous_hop_data());
Copy link
Contributor

Choose a reason for hiding this comment

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

Phantom secret was set to None always, where as now it's taken from forward_info. No problem? Also at the last change in this file.

});

let mut prev_hop = payment.htlc_previous_hop_data();
prev_hop.phantom_shared_secret = phantom_ss;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add a comment why the phantom secret as set in htlc_previous_hop_data() isn't good.

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

$secp_ctx,
&Scalar::from_be_bytes(hop_pk_blinding_factor).unwrap(),
)?
pk.mul_tweak($secp_ctx, &Scalar::from_be_bytes(hop_pk_blinding_factor).unwrap())
Copy link
Contributor

@joostjager joostjager Sep 3, 2025

Choose a reason for hiding this comment

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

Do you know what the original reason was for making an exception here and not panicking for blinded paths specifically? Is there any way in which input causing this could be provided from the outside?

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.

3 participants