Skip to content

Commit 73c6572

Browse files
Remove now-unused ServeStaticInv::inv_slot from OM
In the initially-merged version of the static invoice server protocol, the static invoice server would sometimes have to find a specific static invoice based on (recipient_id, invoice_slot) and sometime based on (recipient_id, invoice_id). This made the API harder to use in terms of how the server would index into the KVStore. We'd like to transition to the server always finding a specific invoice based on (recipient_id, invoice_slot) and get rid of the invoice_id concept. Now that the server includes the invoice_slot in the ServeStaticInvoice blinded path context as added in the previous commit, there is no need for the recipient to include it in the ServeStaticInvoice onion message itself.
1 parent dbe3514 commit 73c6572

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

lightning/src/offers/async_receive_offer_cache.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,10 @@ impl AsyncReceiveOfferCache {
411411
/// the static invoice server.
412412
pub(super) fn offers_needing_invoice_refresh(
413413
&self, duration_since_epoch: Duration,
414-
) -> impl Iterator<Item = (&Offer, Nonce, u16, &Responder)> {
414+
) -> impl Iterator<Item = (&Offer, Nonce, &Responder)> {
415415
// For any offers which are either in use or pending confirmation by the server, we should send
416416
// them a fresh invoice on each timer tick.
417-
self.offers_with_idx().filter_map(move |(idx, offer)| {
417+
self.offers_with_idx().filter_map(move |(_, offer)| {
418418
let needs_invoice_update = match offer.status {
419419
OfferStatus::Used { invoice_created_at } => {
420420
invoice_created_at.saturating_add(INVOICE_REFRESH_THRESHOLD)
@@ -426,13 +426,7 @@ impl AsyncReceiveOfferCache {
426426
OfferStatus::Ready { .. } => false,
427427
};
428428
if needs_invoice_update {
429-
let offer_slot = idx.try_into().unwrap_or(u16::MAX);
430-
Some((
431-
&offer.offer,
432-
offer.offer_nonce,
433-
offer_slot,
434-
&offer.update_static_invoice_path,
435-
))
429+
Some((&offer.offer, offer.offer_nonce, &offer.update_static_invoice_path))
436430
} else {
437431
None
438432
}

lightning/src/offers/flow.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,7 @@ where
13171317
let duration_since_epoch = self.duration_since_epoch();
13181318
let cache = self.async_receive_offer_cache.lock().unwrap();
13191319
for offer_and_metadata in cache.offers_needing_invoice_refresh(duration_since_epoch) {
1320-
let (offer, offer_nonce, slot_number, update_static_invoice_path) =
1321-
offer_and_metadata;
1320+
let (offer, offer_nonce, update_static_invoice_path) = offer_and_metadata;
13221321

13231322
let (invoice, forward_invreq_path) = match self.create_static_invoice_for_server(
13241323
offer,
@@ -1342,7 +1341,6 @@ where
13421341
let serve_invoice_message = ServeStaticInvoice {
13431342
invoice,
13441343
forward_invoice_request_path: forward_invreq_path,
1345-
invoice_slot: slot_number,
13461344
};
13471345
serve_static_invoice_msgs.push((
13481346
serve_invoice_message,
@@ -1517,8 +1515,7 @@ where
15171515
})
15181516
};
15191517

1520-
let serve_invoice_message =
1521-
ServeStaticInvoice { invoice, forward_invoice_request_path, invoice_slot };
1518+
let serve_invoice_message = ServeStaticInvoice { invoice, forward_invoice_request_path };
15221519
Some((serve_invoice_message, reply_path_context))
15231520
}
15241521

lightning/src/onion_message/async_payments.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ pub struct ServeStaticInvoice {
172172
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
173173
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
174174
pub forward_invoice_request_path: BlindedMessagePath,
175-
/// The "slot" in the static invoice server's database that this invoice should go into. This
176-
/// allows recipients to replace a specific invoice that is stored by the server, which is useful
177-
/// for limiting the number of invoices stored by the server while also keeping all the invoices
178-
/// persisted with the server fresh.
179-
pub invoice_slot: u16,
180175
}
181176

182177
/// Confirmation from a static invoice server that a [`StaticInvoice`] was persisted and the
@@ -251,7 +246,6 @@ impl_writeable_tlv_based!(OfferPaths, {
251246
impl_writeable_tlv_based!(ServeStaticInvoice, {
252247
(0, invoice, required),
253248
(2, forward_invoice_request_path, required),
254-
(4, invoice_slot, required),
255249
});
256250

257251
impl_writeable_tlv_based!(StaticInvoicePersisted, {});

0 commit comments

Comments
 (0)