Skip to content

Commit 6d59fb9

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 864f787 commit 6d59fb9

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
@@ -95,6 +95,7 @@ pub(crate) enum PendingOutboundPayment {
9595
retry_strategy: Retry,
9696
route_params: RouteParameters,
9797
invoice_request: InvoiceRequest,
98+
static_invoice: StaticInvoice,
9899
},
99100
Retryable {
100101
retry_strategy: Option<Retry>,
@@ -1162,6 +1163,7 @@ impl OutboundPayments {
11621163
.take()
11631164
.ok_or(Bolt12PaymentError::UnexpectedInvoice)?
11641165
.invoice_request,
1166+
static_invoice: invoice.clone(),
11651167
};
11661168
return Ok(())
11671169
},
@@ -1190,22 +1192,22 @@ impl OutboundPayments {
11901192
IH: Fn() -> InFlightHtlcs,
11911193
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
11921194
{
1193-
let (payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request) =
1195+
let (payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request, invoice) =
11941196
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
11951197
hash_map::Entry::Occupied(entry) => match entry.get() {
11961198
PendingOutboundPayment::StaticInvoiceReceived {
1197-
payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request, ..
1199+
payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request, static_invoice, ..
11981200
} => {
11991201
(*payment_hash, *keysend_preimage, route_params.clone(), *retry_strategy,
1200-
invoice_request.clone())
1202+
invoice_request.clone(), static_invoice.clone())
12011203
},
12021204
_ => return Err(Bolt12PaymentError::DuplicateInvoice),
12031205
},
12041206
hash_map::Entry::Vacant(_) => return Err(Bolt12PaymentError::UnexpectedInvoice),
12051207
};
1206-
1208+
let invoice = PaidInvoice::StaticInvoice(invoice.clone());
12071209
self.send_payment_for_bolt12_invoice_internal(
1208-
payment_id, payment_hash, Some(keysend_preimage), Some(&invoice_request), None, route_params,
1210+
payment_id, payment_hash, Some(keysend_preimage), Some(&invoice_request), Some(&invoice), route_params,
12091211
retry_strategy, router, first_hops, inflight_htlcs, entropy_source, node_signer,
12101212
node_id_lookup, secp_ctx, best_block_height, logger, pending_events, send_payment_along_path
12111213
)
@@ -2529,6 +2531,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
25292531
(4, retry_strategy, required),
25302532
(6, route_params, required),
25312533
(8, invoice_request, required),
2534+
(10, static_invoice, required),
25322535
},
25332536
// Added in 0.1. Prior versions will drop these outbounds on downgrade, which is safe because
25342537
// no HTLCs are in-flight.

0 commit comments

Comments
 (0)