@@ -35,6 +35,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
35
35
36
36
use core:: mem;
37
37
use core:: ops:: Deref ;
38
+ use core:: time:: Duration ;
38
39
39
40
/// A blinded path to be used for sending or receiving a message, hiding the identity of the
40
41
/// recipient.
@@ -342,6 +343,43 @@ pub enum OffersContext {
342
343
/// [`Offer`]: crate::offers::offer::Offer
343
344
nonce : Nonce ,
344
345
} ,
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 rate limiting 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 : u128 ,
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
+ } ,
345
383
/// Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an
346
384
/// [`InvoiceRequest`].
347
385
///
@@ -438,6 +476,38 @@ pub enum AsyncPaymentsContext {
438
476
/// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
439
477
path_absolute_expiry : core:: time:: Duration ,
440
478
} ,
479
+ /// Context used by a reply path to an [`OfferPaths`] message, provided back to us as the static
480
+ /// invoice server in corresponding [`ServeStaticInvoice`] messages.
481
+ ///
482
+ /// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
483
+ /// [`ServeStaticInvoice`]: crate::onion_message::async_payments::ServeStaticInvoice
484
+ ServeStaticInvoice {
485
+ /// An identifier for the async recipient that is requesting that a [`StaticInvoice`] be served
486
+ /// on their behalf.
487
+ ///
488
+ /// Useful for retrieving the invoice when payers send an [`InvoiceRequest`] to us as the static
489
+ /// invoice server. Also useful to rate limit the invoices being persisted on behalf of a
490
+ /// particular recipient. This id will be provided back to us as the static invoice server via
491
+ /// [`OffersContext::StaticInvoiceRequested::recipient_id`]
492
+ ///
493
+ /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
494
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
495
+ recipient_id : Vec < u8 > ,
496
+ /// A random unique identifier for the specific [`StaticInvoice`] that the recipient is
497
+ /// requesting be served on their behalf. Useful when surfaced alongside the above
498
+ /// `recipient_id` when payers send an [`InvoiceRequest`], to pull the specific static invoice
499
+ /// from the database. This id will be provided back to us as the static invoice server via
500
+ /// [`OffersContext::StaticInvoiceRequested::invoice_id`]
501
+ ///
502
+ /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
503
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
504
+ invoice_id : u128 ,
505
+ /// The time as duration since the Unix epoch at which this path expires and messages sent over
506
+ /// it should be ignored.
507
+ ///
508
+ /// Useful to timeout async recipients that are no longer supported as clients.
509
+ path_absolute_expiry : core:: time:: Duration ,
510
+ } ,
441
511
/// Context used by a reply path to a [`ServeStaticInvoice`] message, provided back to us in
442
512
/// corresponding [`StaticInvoicePersisted`] messages.
443
513
///
@@ -526,6 +596,11 @@ impl_writeable_tlv_based_enum!(OffersContext,
526
596
( 1 , nonce, required) ,
527
597
( 2 , hmac, required)
528
598
} ,
599
+ ( 3 , StaticInvoiceRequested ) => {
600
+ ( 0 , recipient_id, required) ,
601
+ ( 2 , invoice_id, required) ,
602
+ ( 4 , path_absolute_expiry, required) ,
603
+ } ,
529
604
) ;
530
605
531
606
impl_writeable_tlv_based_enum ! ( AsyncPaymentsContext ,
@@ -550,6 +625,11 @@ impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
550
625
( 0 , recipient_id, required) ,
551
626
( 2 , path_absolute_expiry, required) ,
552
627
} ,
628
+ ( 5 , ServeStaticInvoice ) => {
629
+ ( 0 , recipient_id, required) ,
630
+ ( 2 , invoice_id, required) ,
631
+ ( 4 , path_absolute_expiry, required) ,
632
+ } ,
553
633
) ;
554
634
555
635
/// Contains a simple nonce for use in a blinded path's context.
0 commit comments