@@ -35,6 +35,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
3535
3636use core:: mem;
3737use core:: ops:: Deref ;
38+ use core:: time:: Duration ;
3839
3940/// A blinded path to be used for sending or receiving a message, hiding the identity of the
4041/// recipient.
@@ -342,6 +343,43 @@ pub enum OffersContext {
342343 /// [`Offer`]: crate::offers::offer::Offer
343344 nonce : Nonce ,
344345 } ,
346+ /// Context used by a [`BlindedMessagePath`] within the [`Offer`] of an async recipient.
347+ ///
348+ /// This variant is received by the static invoice server when handling an [`InvoiceRequest`] on
349+ /// behalf of said async recipient.
350+ ///
351+ /// [`Offer`]: crate::offers::offer::Offer
352+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
353+ StaticInvoiceRequested {
354+ /// An identifier for the async recipient for whom we as a static invoice server are serving
355+ /// [`StaticInvoice`]s. Used paired with the
356+ /// [`OffersContext::StaticInvoiceRequested::invoice_id`] when looking up a corresponding
357+ /// [`StaticInvoice`] to return to the payer if the recipient is offline. This id was previously
358+ /// provided via [`AsyncPaymentsContext::ServeStaticInvoice::recipient_id`].
359+ ///
360+ /// Also useful for to rate limit the number of [`InvoiceRequest`]s we will respond to on
361+ /// recipient's behalf.
362+ ///
363+ /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
364+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
365+ recipient_id : Vec < u8 > ,
366+
367+ /// A random unique identifier for a specific [`StaticInvoice`] that the recipient previously
368+ /// requested be served on their behalf. Useful when paired with the
369+ /// [`OffersContext::StaticInvoiceRequested::recipient_id`] to pull that specific invoice from
370+ /// the database when payers send an [`InvoiceRequest`]. This id was previously
371+ /// provided via [`AsyncPaymentsContext::ServeStaticInvoice::invoice_id`].
372+ ///
373+ /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
374+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
375+ invoice_id : u64 ,
376+
377+ /// The time as duration since the Unix epoch at which this path expires and messages sent over
378+ /// it should be ignored.
379+ ///
380+ /// Useful to timeout async recipients that are no longer supported as clients.
381+ path_absolute_expiry : Duration ,
382+ } ,
345383 /// Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an
346384 /// [`InvoiceRequest`].
347385 ///
@@ -439,6 +477,38 @@ pub enum AsyncPaymentsContext {
439477 /// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
440478 path_absolute_expiry : core:: time:: Duration ,
441479 } ,
480+ /// Context used by a reply path to an [`OfferPaths`] message, provided back to us as the static
481+ /// invoice server in corresponding [`ServeStaticInvoice`] messages.
482+ ///
483+ /// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
484+ /// [`ServeStaticInvoice`]: crate::onion_message::async_payments::ServeStaticInvoice
485+ ServeStaticInvoice {
486+ /// An identifier for the async recipient that is requesting that a [`StaticInvoice`] be served
487+ /// on their behalf.
488+ ///
489+ /// Useful for retrieving the invoice when payers send an [`InvoiceRequest`] to us as the static
490+ /// invoice server. Also useful to rate limit the invoices being persisted on behalf of a
491+ /// particular recipient. This id will be provided back to us as the static invoice server via
492+ /// [`OffersContext::StaticInvoiceRequested::recipient_id`]
493+ ///
494+ /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
495+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
496+ recipient_id : Vec < u8 > ,
497+ /// A random unique identifier for the specific [`StaticInvoice`] that the recipient is
498+ /// requesting be served on their behalf. Useful when surfaced alongside the above
499+ /// `recipient_id` when payers send an [`InvoiceRequest`], to pull the specific static invoice
500+ /// from the database. This id will be provided back to us as the static invoice server via
501+ /// [`OffersContext::StaticInvoiceRequested::invoice_id`]
502+ ///
503+ /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
504+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
505+ invoice_id : u64 ,
506+ /// The time as duration since the Unix epoch at which this path expires and messages sent over
507+ /// it should be ignored.
508+ ///
509+ /// Useful to timeout async recipients that are no longer supported as clients.
510+ path_absolute_expiry : core:: time:: Duration ,
511+ } ,
442512 /// Context used by a reply path to a [`ServeStaticInvoice`] message, provided back to us in
443513 /// corresponding [`StaticInvoicePersisted`] messages.
444514 ///
@@ -527,6 +597,11 @@ impl_writeable_tlv_based_enum!(OffersContext,
527597 ( 1 , nonce, required) ,
528598 ( 2 , hmac, required)
529599 } ,
600+ ( 3 , StaticInvoiceRequested ) => {
601+ ( 0 , recipient_id, required) ,
602+ ( 2 , invoice_id, required) ,
603+ ( 4 , path_absolute_expiry, required) ,
604+ } ,
530605) ;
531606
532607impl_writeable_tlv_based_enum ! ( AsyncPaymentsContext ,
@@ -551,6 +626,11 @@ impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
551626 ( 0 , recipient_id, required) ,
552627 ( 2 , path_absolute_expiry, required) ,
553628 } ,
629+ ( 5 , ServeStaticInvoice ) => {
630+ ( 0 , recipient_id, required) ,
631+ ( 2 , invoice_id, required) ,
632+ ( 4 , path_absolute_expiry, required) ,
633+ } ,
554634) ;
555635
556636/// Contains a simple nonce for use in a blinded path's context.
0 commit comments