Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Bolt11 Payments and Remove Redundant Code #3617

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shaavan
Copy link
Member

@shaavan shaavan commented Feb 24, 2025

resolves #3262
builds on: #3342

Summary

This PR introduces pay_for_bolt11_invoice, simplifying how Bolt11 payments are processed by allowing direct invoice-based payments while still enabling custom routing parameters. With this change, the redundant bolt11_payment.rs utility functions are no longer needed and have been removed.

Why This Change?

  • Previously, paying a Bolt11 invoice required manually extracting payment_id, payment_hash, and other parameters before passing them to send_payment.
  • pay_for_bolt11_invoice introduces a more streamlined approach, mirroring the existing convenience of Bolt12 payments.
  • With this function now handling parameter extraction within ChannelManager, bolt11_payment.rs is redundant and can be safely removed.

Changes

  • Introduced pay_for_bolt11_invoice:
    • Takes a Bolt11 invoice directly.
    • Allows users to set custom routing parameters via RouteParametersConfig.
  • Removed bolt11_payment.rs:
    • All relevant logic is now handled within ChannelManager.
    • Removed associated test cases for redundant utility functions.

Impact

  • Reduces complexity for Bolt11 payments.
  • Cleans up redundant code, making the implementation more maintainable.

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.

Thanks! This needs rebase now.

@jkczyz jkczyz self-requested a review February 25, 2025 15:36
Some upcoming changes require a new `PaymentFailure` variant to handle cases where a
Bolt11 invoice specifies an invalid amount. This commit introduces the variant,
setting the stage for its usage in subsequent commits.
Previously, paying a Bolt11 invoice required manually extracting the
`payment_id`, `payment_hash`, and other parameters before passing them to
`send_payment`.

This commit introduces `pay_for_bolt11_invoice`, bringing the same simplicity
already available for Bolt12 invoices. It allows users to pass the entire
Bolt11 invoice directly while also supporting custom routing parameters
via `RouteParametersConfig`.
With `pay_for_bolt11_invoice` now handling payment and route parameter
extraction within `ChannelManager`, the utility functions in
`bolt11_payment.rs` have become unnecessary. This commit removes the
redundant code and associated tests, streamlining the implementation.
@shaavan
Copy link
Member Author

shaavan commented Feb 26, 2025

Updated from pr3617.01 to pr3617.02 (diff):

Changes:

  1. Rebase on main.

@shaavan
Copy link
Member Author

shaavan commented Feb 26, 2025

Updated from pr3617.02 to pr3617.03 (diff):
Addressed @TheBlueMatt comments

Changes:

  1. Introduce payment_id as parameter, and update documentation

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 84.50704% with 11 lines in your changes missing coverage. Please review.

Project coverage is 88.57%. Comparing base (1610854) to head (16368c0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/outbound_payment.rs 81.57% 3 Missing and 4 partials ⚠️
lightning/src/events/mod.rs 0.00% 2 Missing ⚠️
lightning/src/routing/router.rs 86.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3617      +/-   ##
==========================================
- Coverage   88.60%   88.57%   -0.03%     
==========================================
  Files         151      150       -1     
  Lines      118454   118377      -77     
  Branches   118454   118377      -77     
==========================================
- Hits       104957   104856     -101     
- Misses      10985    10990       +5     
- Partials     2512     2531      +19     

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

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.

thanks!

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.

BOLT12 sending doesn't allow to override {Route,Payment}Parameters
2 participants