Skip to content

Commit 18fb0f2

Browse files
Fix failure to abandon async payments on invalid static invoice
Prior to this fix, we would attempt to mark outbound async payments as abandoned but silently fail because they were in state AwaitingInvoice, which the mark_abandoned utility doesn't currently work for. These payments would eventually be removed by the remove_stale_payments method, but there would be a delay in generating the PaymentFailed event. Move to manually removing the outbound payment entry.
1 parent 1092336 commit 18fb0f2

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

lightning/src/ln/outbound_payment.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -1028,17 +1028,13 @@ impl OutboundPayments {
10281028
) -> Result<(), Bolt12PaymentError> where ES::Target: EntropySource {
10291029
macro_rules! abandon_with_entry {
10301030
($payment: expr, $reason: expr) => {
1031-
$payment.get_mut().mark_abandoned($reason);
1032-
if let PendingOutboundPayment::Abandoned { reason, .. } = $payment.get() {
1033-
if $payment.get().remaining_parts() == 0 {
1034-
pending_events.lock().unwrap().push_back((events::Event::PaymentFailed {
1035-
payment_id,
1036-
payment_hash: None,
1037-
reason: *reason,
1038-
}, None));
1039-
$payment.remove();
1040-
}
1041-
}
1031+
debug_assert!(matches!($payment.get(), PendingOutboundPayment::AwaitingInvoice { .. }));
1032+
pending_events.lock().unwrap().push_back((events::Event::PaymentFailed {
1033+
payment_id,
1034+
payment_hash: None,
1035+
reason: Some($reason),
1036+
}, None));
1037+
$payment.remove();
10421038
}
10431039
}
10441040

0 commit comments

Comments
 (0)