Skip to content

Commit

Permalink
Merge pull request #2037 from valentinewallace/2023-02-fix-probe-leak
Browse files Browse the repository at this point in the history
Fix outbound payments probe leak
  • Loading branch information
TheBlueMatt authored Feb 16, 2023
2 parents 4b043c9 + a2b956d commit a170478
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lightning/src/ln/outbound_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
3 changes: 3 additions & 0 deletions lightning/src/ln/payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ fn successful_probe_yields_event() {
},
_ => panic!(),
};
assert!(!nodes[0].node.has_pending_payments());
}

#[test]
Expand Down Expand Up @@ -986,6 +987,7 @@ fn failed_probe_yields_event() {
},
_ => panic!(),
};
assert!(!nodes[0].node.has_pending_payments());
}

#[test]
Expand Down Expand Up @@ -1040,6 +1042,7 @@ fn onchain_failed_probe_yields_event() {
}
}
assert!(found_probe_failed);
assert!(!nodes[0].node.has_pending_payments());
}

#[test]
Expand Down

0 comments on commit a170478

Please sign in to comment.