Revert "Config-guard Event::InvoiceRequestFailed"
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 12 Oct 2023 21:10:51 +0000 (16:10 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 20 Oct 2023 14:49:57 +0000 (09:49 -0500)
This reverts commit c7219e46831751c52026932294c33fce24121d84.

lightning/src/events/mod.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/outbound_payment.rs

index ca55fde31c5bee711e75693d07cc8dc8b82b52b1..27e69131f073bce6e576ddb1ffaf706a1b649ac0 100644 (file)
@@ -517,7 +517,6 @@ pub enum Event {
        /// or was explicitly abandoned by [`ChannelManager::abandon_payment`].
        ///
        /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
-       #[cfg(invreqfailed)]
        InvoiceRequestFailed {
                /// The `payment_id` to have been associated with payment for the requested invoice.
                payment_id: PaymentId,
@@ -1164,7 +1163,6 @@ impl Writeable for Event {
                                        (8, funding_txo, required),
                                });
                        },
-                       #[cfg(invreqfailed)]
                        &Event::InvoiceRequestFailed { ref payment_id } => {
                                33u8.write(writer)?;
                                write_tlv_fields!(writer, {
@@ -1558,7 +1556,6 @@ impl MaybeReadable for Event {
                                };
                                f()
                        },
-                       #[cfg(invreqfailed)]
                        33u8 => {
                                let f = || {
                                        _init_and_read_len_prefixed_tlv_fields!(reader, {
index 064f6a3529af349481e5d139cc045b21202c5447..ff961370d86c21d2e3f863efab67c1428b5c2541 100644 (file)
@@ -3606,10 +3606,19 @@ where
        /// wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
        /// determine the ultimate status of a payment.
        ///
+       /// # Requested Invoices
+       ///
+       /// In the case of paying a [`Bolt12Invoice`], abandoning the payment prior to receiving the
+       /// invoice will result in an [`Event::InvoiceRequestFailed`] and prevent any attempts at paying
+       /// it once received. The other events may only be generated once the invoice has been received.
+       ///
        /// # Restart Behavior
        ///
        /// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
-       /// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated.
+       /// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
+       /// [`Event::InvoiceRequestFailed`].
+       ///
+       /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
        pub fn abandon_payment(&self, payment_id: PaymentId) {
                let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
                self.pending_outbound_payments.abandon_payment(payment_id, PaymentFailureReason::UserAbandoned, &self.pending_events);
index 2adabebe7e3eca165ec40a3a9f3302c5cf2b47a9..7e58c8adf298c1e7ace9085de66ac04c5913139e 100644 (file)
@@ -1526,9 +1526,6 @@ impl OutboundPayments {
                pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>>)
        {
                let mut pending_outbound_payments = self.pending_outbound_payments.lock().unwrap();
-               #[cfg(not(invreqfailed))]
-               let pending_events = pending_events.lock().unwrap();
-               #[cfg(invreqfailed)]
                let mut pending_events = pending_events.lock().unwrap();
                pending_outbound_payments.retain(|payment_id, payment| match payment {
                        // If an outbound payment was completed, and no pending HTLCs remain, we should remove it
@@ -1578,7 +1575,6 @@ impl OutboundPayments {
                                        },
                                };
                                if is_stale {
-                                       #[cfg(invreqfailed)]
                                        pending_events.push_back(
                                                (events::Event::InvoiceRequestFailed { payment_id: *payment_id }, None)
                                        );
@@ -1734,7 +1730,6 @@ impl OutboundPayments {
                                        payment.remove();
                                }
                        } else if let PendingOutboundPayment::AwaitingInvoice { .. } = payment.get() {
-                               #[cfg(invreqfailed)]
                                pending_events.lock().unwrap().push_back((events::Event::InvoiceRequestFailed {
                                        payment_id,
                                }, None));
@@ -2032,7 +2027,6 @@ mod tests {
        }
 
        #[test]
-       #[cfg(invreqfailed)]
        fn removes_stale_awaiting_invoice_using_absolute_timeout() {
                let pending_events = Mutex::new(VecDeque::new());
                let outbound_payments = OutboundPayments::new();
@@ -2083,7 +2077,6 @@ mod tests {
        }
 
        #[test]
-       #[cfg(invreqfailed)]
        fn removes_stale_awaiting_invoice_using_timer_ticks() {
                let pending_events = Mutex::new(VecDeque::new());
                let outbound_payments = OutboundPayments::new();
@@ -2133,7 +2126,6 @@ mod tests {
        }
 
        #[test]
-       #[cfg(invreqfailed)]
        fn removes_abandoned_awaiting_invoice() {
                let pending_events = Mutex::new(VecDeque::new());
                let outbound_payments = OutboundPayments::new();