@@ -1341,11 +1341,6 @@ const CHECK_CLTV_EXPIRY_SANITY_2: u32 = MIN_CLTV_EXPIRY_DELTA as u32 - LATENCY_G
1341
1341
/// The number of ticks of [`ChannelManager::timer_tick_occurred`] until expiry of incomplete MPPs
1342
1342
pub(crate) const MPP_TIMEOUT_TICKS: u8 = 3;
1343
1343
1344
- /// The number of ticks of [`ChannelManager::timer_tick_occurred`] until we time-out the
1345
- /// idempotency of payments by [`PaymentId`]. See
1346
- /// [`OutboundPayments::remove_stale_resolved_payments`].
1347
- pub(crate) const IDEMPOTENCY_TIMEOUT_TICKS: u8 = 7;
1348
-
1349
1344
/// The number of ticks of [`ChannelManager::timer_tick_occurred`] where a peer is disconnected
1350
1345
/// until we mark the channel disabled and gossip the update.
1351
1346
pub(crate) const DISABLE_GOSSIP_TICKS: u8 = 10;
@@ -1688,6 +1683,11 @@ pub enum ChannelShutdownState {
1688
1683
/// These include payments that have yet to find a successful path, or have unresolved HTLCs.
1689
1684
#[derive(Debug, PartialEq)]
1690
1685
pub enum RecentPaymentDetails {
1686
+ /// When an invoice was requested and thus a payment has not yet been sent.
1687
+ AwaitingInvoice {
1688
+ /// Identifier for the payment to ensure idempotency.
1689
+ payment_id: PaymentId,
1690
+ },
1691
1691
/// When a payment is still being sent and awaiting successful delivery.
1692
1692
Pending {
1693
1693
/// Hash of the payment that is currently being sent but has yet to be fulfilled or
@@ -2419,7 +2419,14 @@ where
2419
2419
/// [`Event::PaymentSent`]: events::Event::PaymentSent
2420
2420
pub fn list_recent_payments(&self) -> Vec<RecentPaymentDetails> {
2421
2421
self.pending_outbound_payments.pending_outbound_payments.lock().unwrap().iter()
2422
- .filter_map(|(_, pending_outbound_payment)| match pending_outbound_payment {
2422
+ .filter_map(|(payment_id, pending_outbound_payment)| match pending_outbound_payment {
2423
+ PendingOutboundPayment::AwaitingInvoice { .. } => {
2424
+ Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
2425
+ },
2426
+ // InvoiceReceived is an intermediate state and doesn't need to be exposed
2427
+ PendingOutboundPayment::InvoiceReceived { .. } => {
2428
+ Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
2429
+ },
2423
2430
PendingOutboundPayment::Retryable { payment_hash, total_msat, .. } => {
2424
2431
Some(RecentPaymentDetails::Pending {
2425
2432
payment_hash: *payment_hash,
@@ -3381,22 +3388,32 @@ where
3381
3388
}
3382
3389
3383
3390
3384
- /// Signals that no further retries for the given payment should occur. Useful if you have a
3391
+ /// Signals that no further attempts for the given payment should occur. Useful if you have a
3385
3392
/// pending outbound payment with retries remaining, but wish to stop retrying the payment before
3386
3393
/// retries are exhausted.
3387
3394
///
3395
+ /// # Event Generation
3396
+ ///
3388
3397
/// If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
3389
3398
/// as there are no remaining pending HTLCs for this payment.
3390
3399
///
3391
3400
/// Note that calling this method does *not* prevent a payment from succeeding. You must still
3392
3401
/// wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
3393
3402
/// determine the ultimate status of a payment.
3394
3403
///
3395
- /// If an [`Event::PaymentFailed`] event is generated and we restart without this
3396
- /// [`ChannelManager`] having been persisted, another [`Event::PaymentFailed`] may be generated.
3404
+ /// # Requested Invoices
3397
3405
///
3398
- /// [`Event::PaymentFailed`]: events::Event::PaymentFailed
3399
- /// [`Event::PaymentSent`]: events::Event::PaymentSent
3406
+ /// In the case of paying a [`Bolt12Invoice`], abandoning the payment prior to receiving the
3407
+ /// invoice will result in an [`Event::InvoiceRequestFailed`] and prevent any attempts at paying
3408
+ /// it once received. The other events may only be generated once the invoice has been received.
3409
+ ///
3410
+ /// # Restart Behavior
3411
+ ///
3412
+ /// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
3413
+ /// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
3414
+ /// [`Event::InvoiceRequestFailed`].
3415
+ ///
3416
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
3400
3417
pub fn abandon_payment(&self, payment_id: PaymentId) {
3401
3418
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
3402
3419
self.pending_outbound_payments.abandon_payment(payment_id, PaymentFailureReason::UserAbandoned, &self.pending_events);
@@ -4655,7 +4672,7 @@ where
4655
4672
let _ = handle_error!(self, err, counterparty_node_id);
4656
4673
}
4657
4674
4658
- self.pending_outbound_payments.remove_stale_resolved_payments (&self.pending_events);
4675
+ self.pending_outbound_payments.remove_stale_payments (&self.pending_events);
4659
4676
4660
4677
// Technically we don't need to do this here, but if we have holding cell entries in a
4661
4678
// channel that need freeing, it's better to do that here and block a background task
@@ -8347,6 +8364,8 @@ where
8347
8364
session_priv.write(writer)?;
8348
8365
}
8349
8366
}
8367
+ PendingOutboundPayment::AwaitingInvoice { .. } => {},
8368
+ PendingOutboundPayment::InvoiceReceived { .. } => {},
8350
8369
PendingOutboundPayment::Fulfilled { .. } => {},
8351
8370
PendingOutboundPayment::Abandoned { .. } => {},
8352
8371
}
0 commit comments