@@ -423,6 +423,26 @@ pub enum InvreqResponseInstructions {
423
423
} ,
424
424
}
425
425
426
+ /// Parameters for the reply path to a [`HeldHtlcAvailable`] onion message.
427
+ pub enum HeldHtlcReplyPath {
428
+ /// The reply path to the [`HeldHtlcAvailable`] message should terminate at our node.
429
+ ToUs {
430
+ /// The id of the payment.
431
+ payment_id : PaymentId ,
432
+ /// The peers to use when creating this reply path.
433
+ peers : Vec < MessageForwardNode > ,
434
+ } ,
435
+ /// The reply path to the [`HeldHtlcAvailable`] message should terminate at our next-hop channel
436
+ /// counterparty, as they are holding our HTLC until they receive the corresponding
437
+ /// [`ReleaseHeldHtlc`] message.
438
+ ///
439
+ /// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
440
+ ToCounterparty {
441
+ /// The blinded path provided to us by our counterparty.
442
+ path : BlindedMessagePath ,
443
+ } ,
444
+ }
445
+
426
446
impl < MR : Deref , L : Deref > OffersMessageFlow < MR , L >
427
447
where
428
448
MR :: Target : MessageRouter ,
@@ -1159,26 +1179,36 @@ where
1159
1179
/// Enqueues `held_htlc_available` onion messages to be sent to the payee via the reply paths
1160
1180
/// contained within the provided [`StaticInvoice`].
1161
1181
///
1162
- /// # Peers
1163
- ///
1164
- /// The user must provide a list of [`MessageForwardNode`] that will be used to generate valid
1165
- /// reply paths for the recipient to send back the corresponding [`ReleaseHeldHtlc`] onion message.
1166
- ///
1167
1182
/// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
1168
1183
/// [`supports_onion_messages`]: crate::types::features::Features::supports_onion_messages
1169
1184
pub fn enqueue_held_htlc_available (
1170
- & self , invoice : & StaticInvoice , payment_id : PaymentId , peers : Vec < MessageForwardNode > ,
1185
+ & self , invoice : & StaticInvoice , reply_path_params : HeldHtlcReplyPath ,
1171
1186
) -> Result < ( ) , Bolt12SemanticError > {
1172
- let context =
1173
- MessageContext :: AsyncPayments ( AsyncPaymentsContext :: OutboundPayment { payment_id } ) ;
1187
+ let reply_path_terminates_at_us =
1188
+ matches ! ( reply_path_params , HeldHtlcReplyPath :: ToUs { .. } ) ;
1174
1189
1175
- let reply_paths = self
1176
- . create_blinded_paths ( peers, context)
1177
- . map_err ( |_| Bolt12SemanticError :: MissingPaths ) ?;
1190
+ let reply_paths = match reply_path_params {
1191
+ HeldHtlcReplyPath :: ToUs { payment_id, peers } => {
1192
+ let context =
1193
+ MessageContext :: AsyncPayments ( AsyncPaymentsContext :: OutboundPayment {
1194
+ payment_id,
1195
+ } ) ;
1196
+ self . create_blinded_paths ( peers, context)
1197
+ . map_err ( |_| {
1198
+ log_trace ! ( self . logger, "Failed to create blinded paths when enqueueing held_htlc_available message" ) ;
1199
+ Bolt12SemanticError :: MissingPaths
1200
+ } ) ?
1201
+ } ,
1202
+ HeldHtlcReplyPath :: ToCounterparty { path } => vec ! [ path] ,
1203
+ } ;
1178
1204
1205
+ log_trace ! (
1206
+ self . logger,
1207
+ "Sending held_htlc_available message for async HTLC, with reply_path terminating at {}" ,
1208
+ if reply_path_terminates_at_us { "our node" } else { "our always-online counterparty" }
1209
+ ) ;
1179
1210
let mut pending_async_payments_messages =
1180
1211
self . pending_async_payments_messages . lock ( ) . unwrap ( ) ;
1181
-
1182
1212
let message = AsyncPaymentsMessage :: HeldHtlcAvailable ( HeldHtlcAvailable { } ) ;
1183
1213
enqueue_onion_message_with_reply_paths (
1184
1214
message,
0 commit comments