Skip to content

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Oct 16, 2025

Recent changes made skimmed_fee_msat a required field of LSPS2ServiceHandler's payment_forwarded API, which seemed reasonable given that the field is available since LDK 0.0.122.

However, the field is of course only set post-0.0.122 when a fee was actually withheld, which makes forcing the user to unwrap_or(0) potentially confusing, especially since our internal logic was written so that it can handle non-intercept-SCID-forwarding cases. Here, we restore the previous idea of "just pass PaymentForwarded fields on, we'll handle the appropriately internally anyways.

Recent changes made `skimmed_fee_msat` a required field of
`LSPS2ServiceHandler`'s `payment_forwarded` API, which seemed reasonable
given that the field is available since LDK 0.0.122.

However, the field is of course only set post-0.0.122 when a fee was
actually withheld, which makes forcing the user to `unwrap_or(0)`
potentially confusing, especially since our internal logic was written
so that it *can* handle non-intercept-SCID-forwarding cases. Here, we
restore the previous idea of "just pass `PaymentForwarded` fields on,
we'll handle the appropriately internally anyways.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 16, 2025

👋 Thanks for assigning @TheBlueMatt 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 Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.77%. Comparing base (b6607a7) to head (0964c7c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4162      +/-   ##
==========================================
- Coverage   88.77%   88.77%   -0.01%     
==========================================
  Files         180      180              
  Lines      136622   136622              
  Branches   136622   136622              
==========================================
- Hits       121293   121289       -4     
- Misses      12517    12525       +8     
+ Partials     2812     2808       -4     
Flag Coverage Δ
fuzzing 20.99% <0.00%> (ø)
tests 88.62% <100.00%> (-0.01%) ⬇️

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.

@tnull tnull added this to the 0.2 milestone Oct 16, 2025
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

I really disagree that we can just make this an Option. I raised it at #3838 (comment) originally, and generally don't think its okay to have an unsafe API here - if someone passes None we really shouldn't be blindly assuming enough was paid (or that there's never enough paid depending on how the comparison works).

@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.

@tnull
Copy link
Contributor Author

tnull commented Oct 17, 2025

I really disagree that we can just make this an Option. I raised it at #3838 (comment) originally, and generally don't think its okay to have an unsafe API here - if someone passes None we really shouldn't be blindly assuming enough was paid (or that there's never enough paid depending on how the comparison works).

Huh, but that's exactly the point: it's not unsafe? We only update the state to PaymentForwarded if if skimmed_fee_msat >= Some(*opening_fee_msat). Otherwise we do nothing. So the idea always has been that you hand-in any forwarded payment data and our logic only acts if there is something to do.

@TheBlueMatt
Copy link
Collaborator

I would still call that "unsafe" - Option in an API implies that its optional, and I'd argue it definitely isn't - if a dev passes None here we'll silently never do anything and never actually open the channel, which is very much incorrect behavior. The LSP might not lose money, but the client is. Making devs actually look at what they're doing and decide, actively, to unwrap_or(0) or just unwrap makes clearer in the calling code what's actually going on vs trying to hide it in LDK.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants