Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lightning/src/ln/async_payments_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ fn pass_async_payments_oms(
.next_onion_message_for_peer(sender_node_id)
.unwrap();
sender.onion_messenger.handle_onion_message(always_online_node_id, &static_invoice_om);
// Check that the node will not lock in HTLCs yet.
sender.node.process_pending_htlc_forwards();
assert!(sender.node.get_and_clear_pending_msg_events().is_empty());

let held_htlc_available_om_0_1 =
sender.onion_messenger.next_onion_message_for_peer(always_online_node_id).unwrap();
Expand Down
12 changes: 8 additions & 4 deletions lightning/src/ln/outbound_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,13 @@ impl PendingOutboundPayment {
params.insert_previously_failed_blinded_path(blinded_tail);
}
}
fn is_awaiting_invoice(&self) -> bool {
// Used for payments to BOLT 12 offers where we are either waiting for an invoice or have an
// invoice but have not locked in HTLCs for the payment yet.
fn is_pre_htlc_lock_in(&self) -> bool {
match self {
PendingOutboundPayment::AwaitingInvoice { .. } => true,
PendingOutboundPayment::AwaitingInvoice { .. }
| PendingOutboundPayment::InvoiceReceived { .. }
Copy link
Contributor

@joostjager joostjager Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First I thought InvoiceReceived isn't necessary, because the payment is initiated immediately after receiving the invoice. But on a closer look, I think there are also similar gaps that require this check. There is also manual bolt12 invoice payment. No test coverage though I think.

| PendingOutboundPayment::StaticInvoiceReceived { .. } => true,
_ => false,
}
}
Expand Down Expand Up @@ -1368,7 +1372,7 @@ impl OutboundPayments {
let mut retain = true;
if !pmt.is_auto_retryable_now()
&& pmt.remaining_parts() == 0
&& !pmt.is_awaiting_invoice()
&& !pmt.is_pre_htlc_lock_in()
{
pmt.mark_abandoned(PaymentFailureReason::RetriesExhausted);
if let PendingOutboundPayment::Abandoned { payment_hash, reason, .. } = pmt {
Expand Down Expand Up @@ -1396,7 +1400,7 @@ impl OutboundPayments {
|| !pmt.is_auto_retryable_now()
&& pmt.remaining_parts() == 0
&& !pmt.is_fulfilled()
&& !pmt.is_awaiting_invoice()
&& !pmt.is_pre_htlc_lock_in()
})
}

Expand Down
Loading