Skip to content

Commit 0a9be8e

Browse files
Include invreq in payment onion when sending async payments.
1 parent 7894e82 commit 0a9be8e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,20 +950,26 @@ impl OutboundPayments {
950950
payment_hash, recipient_onion.clone(), keysend_preimage, &route, Some(retry_strategy),
951951
payment_params, entropy_source, best_block_height
952952
);
953-
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
954-
hash_map::Entry::Occupied(entry) => match entry.get() {
955-
PendingOutboundPayment::InvoiceReceived { .. }
956-
| PendingOutboundPayment::StaticInvoiceReceived { .. } => {
957-
*entry.into_mut() = retryable_payment;
953+
let mut invoice_request_opt = None;
954+
let mut outbounds = self.pending_outbound_payments.lock().unwrap();
955+
match outbounds.entry(payment_id) {
956+
hash_map::Entry::Occupied(entry) => match entry.remove() {
957+
PendingOutboundPayment::InvoiceReceived { .. } => {
958+
outbounds.insert(payment_id, retryable_payment);
959+
},
960+
PendingOutboundPayment::StaticInvoiceReceived { invoice_request, .. } => {
961+
invoice_request_opt = Some(invoice_request);
962+
outbounds.insert(payment_id, retryable_payment);
958963
},
959964
_ => return Err(Bolt12PaymentError::DuplicateInvoice),
960965
},
961966
hash_map::Entry::Vacant(_) => return Err(Bolt12PaymentError::UnexpectedInvoice),
962967
}
968+
core::mem::drop(outbounds);
963969

964970
let result = self.pay_route_internal(
965-
&route, payment_hash, &recipient_onion, keysend_preimage, None, payment_id,
966-
Some(route_params.final_value_msat), onion_session_privs, node_signer,
971+
&route, payment_hash, &recipient_onion, keysend_preimage, invoice_request_opt.as_ref(),
972+
payment_id, Some(route_params.final_value_msat), onion_session_privs, node_signer,
967973
best_block_height, &send_payment_along_path
968974
);
969975
log_info!(

0 commit comments

Comments
 (0)