Skip to content

Commit 85c3f73

Browse files
f store static invoice inside the PendingOutboundPayment::StaticInvoiceReceived
This is tricky because we need to work with the conditional compilation and inside macros that persist this event the conditional compilation is not available (if I understand correctly). Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 3fa7131 commit 85c3f73

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ pub(crate) enum PendingOutboundPayment {
9494
retry_strategy: Retry,
9595
route_params: RouteParameters,
9696
invoice_request: InvoiceRequest,
97+
#[cfg(async_payments)]
98+
static_invoice: StaticInvoice,
9799
},
98100
Retryable {
99101
retry_strategy: Option<Retry>,
@@ -1101,6 +1103,7 @@ impl OutboundPayments {
11011103
.take()
11021104
.ok_or(Bolt12PaymentError::UnexpectedInvoice)?
11031105
.invoice_request,
1106+
static_invoice: invoice.clone(),
11041107
};
11051108
return Ok(())
11061109
},
@@ -1129,22 +1132,22 @@ impl OutboundPayments {
11291132
IH: Fn() -> InFlightHtlcs,
11301133
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
11311134
{
1132-
let (payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request) =
1135+
let (payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request, invoice) =
11331136
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
11341137
hash_map::Entry::Occupied(entry) => match entry.get() {
11351138
PendingOutboundPayment::StaticInvoiceReceived {
1136-
payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request, ..
1139+
payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request, static_invoice, ..
11371140
} => {
11381141
(*payment_hash, *keysend_preimage, route_params.clone(), *retry_strategy,
1139-
invoice_request.clone())
1142+
invoice_request.clone(), static_invoice.clone())
11401143
},
11411144
_ => return Err(Bolt12PaymentError::DuplicateInvoice),
11421145
},
11431146
hash_map::Entry::Vacant(_) => return Err(Bolt12PaymentError::UnexpectedInvoice),
11441147
};
1145-
1148+
let invoice = PaidInvoice::StaticInvoice(invoice.clone());
11461149
self.send_payment_for_bolt12_invoice_internal(
1147-
payment_id, payment_hash, Some(keysend_preimage), Some(&invoice_request), None, route_params,
1150+
payment_id, payment_hash, Some(keysend_preimage), Some(&invoice_request), Some(&invoice), route_params,
11481151
retry_strategy, router, first_hops, inflight_htlcs, entropy_source, node_signer,
11491152
node_id_lookup, secp_ctx, best_block_height, logger, pending_events, send_payment_along_path
11501153
)

0 commit comments

Comments
 (0)