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

refactored payment_parameters_from_zero_amount_invoice to amount-less #2979

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

srikanth-iyengar
Copy link

Fix #2879
Refactored payment_parameters_from_zero_amount_invoice to amount-less as per the discussion in the issue

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

The changes look good. Just one small nit.

I think it will be a good idea to amend the payment_parameters_from_amount_less_invoice documentation so that readers can understand that zero-amount invoices are synonymous with amount-less invoices in this context.

@srikanth-iyengar
Copy link
Author

The changes look good. Just one small nit.

I think it will be a good idea to amend the payment_parameters_from_amount_less_invoice documentation so that readers can understand that zero-amount invoices are synonymous with amount-less invoices in this context.

Ohk will add the documentation

@srikanth-iyengar
Copy link
Author

@shaavan should I add the doc just below this ?

/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
/// [`ChannelManager::send_preflight_probes`].
///
/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
/// same [`PaymentHash`] has never been paid before.
///
/// Will always succeed unless the invoice has an amount specified, in which case
/// [`payment_parameters_from_invoice`] should be used.
///

@shaavan
Copy link
Contributor

shaavan commented Apr 3, 2024

I was thinking maybe something simple like this may also work

 /// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
-/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
+/// (amount-less) [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
 /// [`ChannelManager::send_preflight_probes`].

But feel free to handle it in whichever way you prefer!

@srikanth-iyengar
Copy link
Author

Got it 👍

@@ -28,7 +28,7 @@ use lightning::routing::router::{PaymentParameters, RouteParameters};
///
/// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
/// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
pub fn payment_parameters_from_zero_amount_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
pub fn payment_parameters_from_amount_less_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be either amountless (one word) or no_amount, I think.

Copy link
Author

Choose a reason for hiding this comment

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

refactoring to amountless

@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.08%. Comparing base (51926f1) to head (e9d9a81).
Report is 105 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2979      +/-   ##
==========================================
- Coverage   89.38%   89.08%   -0.30%     
==========================================
  Files         117      118       +1     
  Lines       95513    97492    +1979     
  Branches    95513    97492    +1979     
==========================================
+ Hits        85376    86854    +1478     
- Misses       7913     8387     +474     
- Partials     2224     2251      +27     

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

Comment on lines 28 to 29
/// An amount-less invoice, also known as a zero-amount invoice, refers to an invoice
/// where the amount to be paid is zero. In this context, both terms are used synonymously.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the added docs are conveying the wrong message here.
A zero-amount invoice doesn't mean the amount to be paid is zero, but rather any arbitrary amount can be paid by the sender. For context, this answer might be helpful.

Also, FWIW, we don't need to explain the meaning of zero-amount invoice here, as the users of this function would most probably be aware of it.
That's why, I think a simple indication that zero-amount ≈ amountless will suffice here.

Copy link
Author

Choose a reason for hiding this comment

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

Got it will change the docs accordingly

@srikanth-iyengar srikanth-iyengar force-pushed the refactor/2879 branch 2 times, most recently from 62b0fa9 to e897bf3 Compare April 7, 2024 01:27
lightning-invoice/src/payment.rs Outdated Show resolved Hide resolved
@@ -17,7 +17,7 @@ use lightning::ln::channelmanager::RecipientOnionFields;
use lightning::routing::router::{PaymentParameters, RouteParameters};

/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
/// (amountless) [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given the functions are called amountless, maybe we should say "amountless (sometimes referred to as zero-amount)"?

Copy link
Author

Choose a reason for hiding this comment

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

- /// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
+ /// amountless (sometimes referred to as zero-amount) [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or

like this ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes?

@TheBlueMatt
Copy link
Collaborator

Please make your commit message more descriptive, see https://cbea.ms/git-commit/ for some guidelines.

@srikanth-iyengar srikanth-iyengar force-pushed the refactor/2879 branch 3 times, most recently from bac2f07 to 1c75d98 Compare April 16, 2024 02:28
@@ -17,7 +17,7 @@ use lightning::ln::channelmanager::RecipientOnionFields;
use lightning::routing::router::{PaymentParameters, RouteParameters};

/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
/// amountless (sometimes referred to as zero-amount) [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
Copy link
Collaborator

Choose a reason for hiding this comment

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

This now reads "zero-amount amountless (sometimes referred to as zero-amount)"

refactored the code related to zero_amount in the lightning payment invoice to use the term "amountless" instead
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.

Rename payment_parameters_from_zero_amount_invoice to imply amount-less, not 0-amount
4 participants