]> git.bitcoin.ninja Git - rust-lightning/commitdiff
rename pay_parameters for no amount invoice
authorVincenzo Palazzo <vincenzopalazzodev@gmail.com>
Tue, 5 Nov 2024 11:45:01 +0000 (12:45 +0100)
committerVincenzo Palazzo <vincenzopalazzodev@gmail.com>
Wed, 6 Nov 2024 10:08:25 +0000 (11:08 +0100)
This commit renames the function `pay_parameters_for_zero_amount_invoice`
to `pay_parameters_for_variable_amount_invoice`.

The term "variable amount" is used to align with
the naming convention in the LDK node, helping to avoid
confusion between similar packages.

Fixes: https://github.com/lightningdevkit/rust-lightning/issues/2879
Replaces: https://github.com/lightningdevkit/rust-lightning/pull/2979
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
lightning/src/ln/bolt11_payment.rs

index 2f2e60f12b507cdd53f7f321a742c72c13dc4466..232183cdb70c903497f64c8115e198a559717478 100644 (file)
@@ -16,9 +16,9 @@ use crate::ln::channelmanager::RecipientOnionFields;
 use crate::routing::router::{PaymentParameters, RouteParameters};
 use crate::types::payment::PaymentHash;
 
-/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
-/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
-/// [`ChannelManager::send_preflight_probes`].
+/// Builds the necessary parameters to pay or pre-flight probe the given variable-amount
+/// (also known as '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.
@@ -28,7 +28,7 @@ use crate::types::payment::PaymentHash;
 ///
 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
 /// [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes
-pub fn payment_parameters_from_zero_amount_invoice(
+pub fn payment_parameters_from_variable_amount_invoice(
        invoice: &Bolt11Invoice, amount_msat: u64,
 ) -> Result<(PaymentHash, RecipientOnionFields, RouteParameters), ()> {
        if invoice.amount_milli_satoshis().is_some() {
@@ -45,7 +45,7 @@ pub fn payment_parameters_from_zero_amount_invoice(
 /// same [`PaymentHash`] has never been paid before.
 ///
 /// Will always succeed unless the invoice has no amount specified, in which case
-/// [`payment_parameters_from_zero_amount_invoice`] should be used.
+/// [`payment_parameters_from_variable_amount_invoice`] should be used.
 ///
 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
 /// [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes
@@ -112,7 +112,7 @@ mod tests {
                        .build_signed(|hash| secp_ctx.sign_ecdsa_recoverable(hash, &private_key))
                        .unwrap();
 
-               assert!(payment_parameters_from_zero_amount_invoice(&invoice, 42).is_err());
+               assert!(payment_parameters_from_variable_amount_invoice(&invoice, 42).is_err());
 
                let (hash, onion, params) = payment_parameters_from_invoice(&invoice).unwrap();
                assert_eq!(&hash.0[..], &payment_hash[..]);
@@ -146,7 +146,7 @@ mod tests {
                assert!(payment_parameters_from_invoice(&invoice).is_err());
 
                let (hash, onion, params) =
-                       payment_parameters_from_zero_amount_invoice(&invoice, 42).unwrap();
+                       payment_parameters_from_variable_amount_invoice(&invoice, 42).unwrap();
                assert_eq!(&hash.0[..], &payment_hash[..]);
                assert_eq!(onion.payment_secret, Some(PaymentSecret([0; 32])));
                assert_eq!(params.final_value_msat, 42);