Skip to content

Commit 51dd344

Browse files
committed
Expand InvoicePayer documentation somewhat to clarify edge-cases
1 parent d73e434 commit 51dd344

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning-invoice/src/payment.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ pub trait Router<S: routing::Score> {
175175
}
176176

177177
/// Number of attempts to retry payment path failures for an [`Invoice`].
178+
///
179+
/// Note that this is the number of *path* failures, not full payment retries. For multi-path
180+
/// payments, if this is less than the total number of paths, we will never even retry all of the
181+
/// payment's paths.
178182
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
179183
pub struct RetryAttempts(pub usize);
180184

@@ -216,6 +220,10 @@ where
216220
}
217221

218222
/// Pays the given [`Invoice`], caching it for later use in case a retry is needed.
223+
///
224+
/// You should ensure that the `invoice.payment_hash()` is unique and the same payment_hash has
225+
/// never been paid before. Because [`InvoicePayer`] is stateless no effort is made to do so
226+
/// for you.
219227
pub fn pay_invoice(&self, invoice: &Invoice) -> Result<PaymentId, PaymentError> {
220228
if invoice.amount_milli_satoshis().is_none() {
221229
Err(PaymentError::Invoice("amount missing"))
@@ -226,6 +234,10 @@ where
226234

227235
/// Pays the given zero-value [`Invoice`] using the given amount, caching it for later use in
228236
/// case a retry is needed.
237+
///
238+
/// You should ensure that the `invoice.payment_hash()` is unique and the same payment_hash has
239+
/// never been paid before. Because [`InvoicePayer`] is stateless no effort is made to do so
240+
/// for you.
229241
pub fn pay_zero_value_invoice(
230242
&self, invoice: &Invoice, amount_msats: u64
231243
) -> Result<PaymentId, PaymentError> {

0 commit comments

Comments
 (0)