Skip to content

Commit

Permalink
add doc for refactored from zero amount to amount less
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-iyengar committed Apr 5, 2024
1 parent 1f2fb4f commit 6442618
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lightning-invoice/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ use lightning::routing::router::{PaymentParameters, RouteParameters};
///
/// Will always succeed unless the invoice has an amount specified, in which case
/// [`payment_parameters_from_invoice`] should be used.
/// 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.
///
/// [`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_amount_less_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
pub fn payment_parameters_from_amountless_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
-> Result<(PaymentHash, RecipientOnionFields, RouteParameters), ()> {
if invoice.amount_milli_satoshis().is_some() {
Err(())
Expand Down Expand Up @@ -120,7 +122,7 @@ mod tests {
})
.unwrap();

assert!(payment_parameters_from_amount_less_invoice(&invoice, 42).is_err());
assert!(payment_parameters_from_amountless_invoice(&invoice, 42).is_err());

let (hash, onion, params) = payment_parameters_from_invoice(&invoice).unwrap();
assert_eq!(&hash.0[..], &payment_hash[..]);
Expand Down Expand Up @@ -154,7 +156,7 @@ mod tests {

assert!(payment_parameters_from_invoice(&invoice).is_err());

let (hash, onion, params) = payment_parameters_from_amount_less_invoice(&invoice, 42).unwrap();
let (hash, onion, params) = payment_parameters_from_amountless_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);
Expand Down

0 comments on commit 6442618

Please sign in to comment.