]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove pending probes on update_fail
authorValentine Wallace <vwallace@protonmail.com>
Wed, 15 Feb 2023 22:30:47 +0000 (17:30 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 16 Feb 2023 04:30:46 +0000 (23:30 -0500)
Previously we had a memory leak where probes would not be removed from
outbound_payments on htlc fail

lightning/src/ln/outbound_payment.rs
lightning/src/ln/payment_tests.rs

index 490aa90697de9581ab493d2cf71c02fbc88e4300..8cb5a07ca68ec7b2aa853e83f924ca5028a7cca2 100644 (file)
@@ -1062,17 +1062,19 @@ impl OutboundPayments {
                                });
                        }
 
-                       if !payment_is_probe && (!is_retryable_now || !payment_retryable || retry.is_none()) {
+                       if payment_is_probe || !is_retryable_now || !payment_retryable || retry.is_none() {
                                let _ = payment.get_mut().mark_abandoned(); // we'll only Err if it's a legacy payment
                                is_retryable_now = false;
                        }
                        if payment.get().remaining_parts() == 0 {
                                all_paths_failed = true;
                                if payment.get().abandoned() {
-                                       full_failure_ev = Some(events::Event::PaymentFailed {
-                                               payment_id: *payment_id,
-                                               payment_hash: payment.get().payment_hash().expect("PendingOutboundPayments::RetriesExceeded always has a payment hash set"),
-                                       });
+                                       if !payment_is_probe {
+                                               full_failure_ev = Some(events::Event::PaymentFailed {
+                                                       payment_id: *payment_id,
+                                                       payment_hash: payment.get().payment_hash().expect("PendingOutboundPayments::RetriesExceeded always has a payment hash set"),
+                                               });
+                                       }
                                        payment.remove();
                                }
                        }
index a433f796a3f9a167a2d23497e879e501049465c7..e398ce0319d7317c386a03db2b4c2ca2197eb014 100644 (file)
@@ -941,6 +941,7 @@ fn successful_probe_yields_event() {
                },
                _ => panic!(),
        };
+       assert!(!nodes[0].node.has_pending_payments());
 }
 
 #[test]
@@ -986,6 +987,7 @@ fn failed_probe_yields_event() {
                },
                _ => panic!(),
        };
+       assert!(!nodes[0].node.has_pending_payments());
 }
 
 #[test]
@@ -1040,6 +1042,7 @@ fn onchain_failed_probe_yields_event() {
                }
        }
        assert!(found_probe_failed);
+       assert!(!nodes[0].node.has_pending_payments());
 }
 
 #[test]