@@ -280,6 +280,10 @@ pub enum MessageContext {
280
280
///
281
281
/// [`OffersMessage`]: crate::onion_message::offers::OffersMessage
282
282
Offers ( OffersContext ) ,
283
+ /// Context specific to an [`AsyncPaymentsMessage`].
284
+ ///
285
+ /// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
286
+ AsyncPayments ( AsyncPaymentsContext ) ,
283
287
/// Context specific to a [`CustomOnionMessageHandler::CustomMessage`].
284
288
///
285
289
/// [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage
@@ -363,9 +367,41 @@ pub enum OffersContext {
363
367
} ,
364
368
}
365
369
370
+ /// Contains data specific to an [`AsyncPaymentsMessage`].
371
+ ///
372
+ /// [`AsyncPaymentsMessage`]: crate::onion_message::async_payments::AsyncPaymentsMessage
373
+ #[ derive( Clone , Debug ) ]
374
+ pub enum AsyncPaymentsContext {
375
+ /// Context contained within the reply [`BlindedMessagePath`] we put in outbound
376
+ /// [`HeldHtlcAvailable`] messages, provided back to us in corresponding [`ReleaseHeldHtlc`]
377
+ /// messages.
378
+ ///
379
+ /// [`HeldHtlcAvailable`]: crate::onion_message::async_payments::HeldHtlcAvailable
380
+ /// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
381
+ OutboundPayment {
382
+ /// ID used when payment to the originating [`Offer`] was initiated. Useful for us to identify
383
+ /// which of our pending outbound payments should be released to its often-offline payee.
384
+ ///
385
+ /// [`Offer`]: crate::offers::offer::Offer
386
+ payment_id : PaymentId ,
387
+ /// A nonce used for authenticating that a [`ReleaseHeldHtlc`] message is valid for a preceding
388
+ /// [`HeldHtlcAvailable`] message.
389
+ ///
390
+ /// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
391
+ /// [`HeldHtlcAvailable`]: crate::onion_message::async_payments::HeldHtlcAvailable
392
+ nonce : Nonce ,
393
+ /// Authentication code for the [`PaymentId`].
394
+ ///
395
+ /// Prevents the recipient from being able to deanonymize us by creating a blinded path to us
396
+ /// containing the expected [`PaymentId`].
397
+ hmac : Hmac < Sha256 > ,
398
+ } ,
399
+ }
400
+
366
401
impl_writeable_tlv_based_enum ! ( MessageContext ,
367
402
{ 0 , Offers } => ( ) ,
368
403
{ 1 , Custom } => ( ) ,
404
+ { 2 , AsyncPayments } => ( ) ,
369
405
) ;
370
406
371
407
impl_writeable_tlv_based_enum ! ( OffersContext ,
@@ -384,6 +420,14 @@ impl_writeable_tlv_based_enum!(OffersContext,
384
420
} ,
385
421
) ;
386
422
423
+ impl_writeable_tlv_based_enum ! ( AsyncPaymentsContext ,
424
+ ( 0 , OutboundPayment ) => {
425
+ ( 0 , payment_id, required) ,
426
+ ( 2 , nonce, required) ,
427
+ ( 4 , hmac, required) ,
428
+ } ,
429
+ ) ;
430
+
387
431
/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.
388
432
pub ( super ) fn blinded_hops < T : secp256k1:: Signing + secp256k1:: Verification > (
389
433
secp_ctx : & Secp256k1 < T > , intermediate_nodes : & [ MessageForwardNode ] ,
0 commit comments