Skip to content

Commit 4364dc2

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 764522d commit 4364dc2

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,7 @@ pub(crate) enum PendingOutboundPayment {
9494
retry_strategy: Retry,
9595
route_params: RouteParameters,
9696
invoice_request: InvoiceRequest,
97+
static_invoice: StaticInvoice,
9798
},
9899
Retryable {
99100
retry_strategy: Option<Retry>,
@@ -1101,6 +1102,7 @@ impl OutboundPayments {
11011102
.take()
11021103
.ok_or(Bolt12PaymentError::UnexpectedInvoice)?
11031104
.invoice_request,
1105+
static_invoice: invoice.clone(),
11041106
};
11051107
return Ok(())
11061108
},
@@ -1129,22 +1131,22 @@ impl OutboundPayments {
11291131
IH: Fn() -> InFlightHtlcs,
11301132
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
11311133
{
1132-
let (payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request) =
1134+
let (payment_hash, keysend_preimage, route_params, retry_strategy, invoice_request, invoice) =
11331135
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
11341136
hash_map::Entry::Occupied(entry) => match entry.get() {
11351137
PendingOutboundPayment::StaticInvoiceReceived {
1136-
payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request, ..
1138+
payment_hash, route_params, retry_strategy, keysend_preimage, invoice_request, static_invoice, ..
11371139
} => {
11381140
(*payment_hash, *keysend_preimage, route_params.clone(), *retry_strategy,
1139-
invoice_request.clone())
1141+
invoice_request.clone(), static_invoice.clone())
11401142
},
11411143
_ => return Err(Bolt12PaymentError::DuplicateInvoice),
11421144
},
11431145
hash_map::Entry::Vacant(_) => return Err(Bolt12PaymentError::UnexpectedInvoice),
11441146
};
1145-
1147+
let invoice = PaidInvoice::StaticInvoice(invoice.clone());
11461148
self.send_payment_for_bolt12_invoice_internal(
1147-
payment_id, payment_hash, Some(keysend_preimage), Some(&invoice_request), None, route_params,
1149+
payment_id, payment_hash, Some(keysend_preimage), Some(&invoice_request), Some(&invoice), route_params,
11481150
retry_strategy, router, first_hops, inflight_htlcs, entropy_source, node_signer,
11491151
node_id_lookup, secp_ctx, best_block_height, logger, pending_events, send_payment_along_path
11501152
)
@@ -2468,6 +2470,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
24682470
(4, retry_strategy, required),
24692471
(6, route_params, required),
24702472
(8, invoice_request, required),
2473+
(10, static_invoice, required),
24712474
},
24722475
// Added in 0.1. Prior versions will drop these outbounds on downgrade, which is safe because
24732476
// no HTLCs are in-flight.

0 commit comments

Comments
 (0)