Skip to content

Commit b002e43

Browse files
authored
Merge pull request #4078 from valentinewallace/2025-09-abandon-async-payment-fix
Don't auto-fail offers payments pre-HTLC lock in
2 parents c7c87ac + ebb8e79 commit b002e43

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lightning/src/ln/async_payments_tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ fn pass_async_payments_oms(
240240
.next_onion_message_for_peer(sender_node_id)
241241
.unwrap();
242242
sender.onion_messenger.handle_onion_message(always_online_node_id, &static_invoice_om);
243+
// Check that the node will not lock in HTLCs yet.
244+
sender.node.process_pending_htlc_forwards();
245+
assert!(sender.node.get_and_clear_pending_msg_events().is_empty());
243246

244247
let held_htlc_available_om_0_1 =
245248
sender.onion_messenger.next_onion_message_for_peer(always_online_node_id).unwrap();

lightning/src/ln/outbound_payment.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ impl PendingOutboundPayment {
219219
params.insert_previously_failed_blinded_path(blinded_tail);
220220
}
221221
}
222-
fn is_awaiting_invoice(&self) -> bool {
222+
// Used for payments to BOLT 12 offers where we are either waiting for an invoice or have an
223+
// invoice but have not locked in HTLCs for the payment yet.
224+
fn is_pre_htlc_lock_in(&self) -> bool {
223225
match self {
224-
PendingOutboundPayment::AwaitingInvoice { .. } => true,
226+
PendingOutboundPayment::AwaitingInvoice { .. }
227+
| PendingOutboundPayment::InvoiceReceived { .. }
228+
| PendingOutboundPayment::StaticInvoiceReceived { .. } => true,
225229
_ => false,
226230
}
227231
}
@@ -1370,7 +1374,7 @@ impl OutboundPayments {
13701374
let mut retain = true;
13711375
if !pmt.is_auto_retryable_now()
13721376
&& pmt.remaining_parts() == 0
1373-
&& !pmt.is_awaiting_invoice()
1377+
&& !pmt.is_pre_htlc_lock_in()
13741378
{
13751379
pmt.mark_abandoned(PaymentFailureReason::RetriesExhausted);
13761380
if let PendingOutboundPayment::Abandoned { payment_hash, reason, .. } = pmt {
@@ -1398,7 +1402,7 @@ impl OutboundPayments {
13981402
|| !pmt.is_auto_retryable_now()
13991403
&& pmt.remaining_parts() == 0
14001404
&& !pmt.is_fulfilled()
1401-
&& !pmt.is_awaiting_invoice()
1405+
&& !pmt.is_pre_htlc_lock_in()
14021406
})
14031407
}
14041408

0 commit comments

Comments
 (0)