@@ -195,6 +195,12 @@ pub enum PendingHTLCRouting {
195
195
/// [`Event::PaymentClaimable::onion_fields`] as
196
196
/// [`RecipientOnionFields::sender_custom_tlvs`].
197
197
sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
198
+ /// Custom TLVs set by the receiver in the blinded path used to reach them.
199
+ ///
200
+ /// For HTLCs received by LDK, this will be exposed in
201
+ /// [`Event::PaymentClaimable::onion_fields`] as
202
+ /// [`RecipientOnionFields::user_custom_data`].
203
+ user_custom_data: Vec<u8>,
198
204
/// Set if this HTLC is the final hop in a multi-hop blinded path.
199
205
requires_blinded_error: bool,
200
206
},
@@ -225,6 +231,11 @@ pub enum PendingHTLCRouting {
225
231
/// For HTLCs received by LDK, these will ultimately bubble back up as
226
232
/// [`RecipientOnionFields::sender_custom_tlvs`].
227
233
sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
234
+ /// Custom TLVs set by the receiver in the blinded path used to reach them.
235
+ ///
236
+ /// For HTLCs received by LDK, these will ultimately bubble back up as
237
+ /// [`RecipientOnionFields::user_custom_data`].
238
+ user_custom_data: Vec<u8>,
228
239
/// Set if this HTLC is the final hop in a multi-hop blinded path.
229
240
requires_blinded_error: bool,
230
241
/// Set if we are receiving a keysend to a blinded path, meaning we created the
@@ -6052,24 +6063,25 @@ where
6052
6063
PendingHTLCRouting::Receive {
6053
6064
payment_data, payment_metadata, payment_context,
6054
6065
incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs,
6055
- requires_blinded_error: _
6066
+ user_custom_data, requires_blinded_error: _
6056
6067
} => {
6057
6068
let _legacy_hop_data = Some(payment_data.clone());
6058
6069
let onion_fields = RecipientOnionFields { payment_secret: Some(payment_data.payment_secret),
6059
- payment_metadata, sender_custom_tlvs };
6070
+ payment_metadata, sender_custom_tlvs, user_custom_data };
6060
6071
(incoming_cltv_expiry, OnionPayload::Invoice { _legacy_hop_data },
6061
6072
Some(payment_data), payment_context, phantom_shared_secret, onion_fields,
6062
6073
true)
6063
6074
},
6064
6075
PendingHTLCRouting::ReceiveKeysend {
6065
6076
payment_data, payment_preimage, payment_metadata,
6066
- incoming_cltv_expiry, sender_custom_tlvs, requires_blinded_error: _ ,
6067
- has_recipient_created_payment_secret,
6077
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_data ,
6078
+ requires_blinded_error: _, has_recipient_created_payment_secret,
6068
6079
} => {
6069
6080
let onion_fields = RecipientOnionFields {
6070
6081
payment_secret: payment_data.as_ref().map(|data| data.payment_secret),
6071
6082
payment_metadata,
6072
6083
sender_custom_tlvs,
6084
+ user_custom_data
6073
6085
};
6074
6086
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
6075
6087
payment_data, None, None, onion_fields, has_recipient_created_payment_secret)
@@ -12392,6 +12404,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12392
12404
(5, sender_custom_tlvs, optional_vec),
12393
12405
(7, requires_blinded_error, (default_value, false)),
12394
12406
(9, payment_context, option),
12407
+ (11, user_custom_data, optional_vec),
12395
12408
},
12396
12409
(2, ReceiveKeysend) => {
12397
12410
(0, payment_preimage, required),
@@ -12401,6 +12414,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12401
12414
(4, payment_data, option), // Added in 0.0.116
12402
12415
(5, sender_custom_tlvs, optional_vec),
12403
12416
(7, has_recipient_created_payment_secret, (default_value, false)),
12417
+ (9, user_custom_data, optional_vec),
12404
12418
},
12405
12419
);
12406
12420
@@ -15365,7 +15379,7 @@ mod tests {
15365
15379
payment_data: Some(msgs::FinalOnionHopData {
15366
15380
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15367
15381
}),
15368
- sender_custom_tlvs: Vec::new(),
15382
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15369
15383
};
15370
15384
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15371
15385
// intended amount, we fail the payment.
@@ -15387,7 +15401,7 @@ mod tests {
15387
15401
payment_data: Some(msgs::FinalOnionHopData {
15388
15402
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15389
15403
}),
15390
- sender_custom_tlvs: Vec::new(),
15404
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15391
15405
};
15392
15406
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15393
15407
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15411,7 +15425,7 @@ mod tests {
15411
15425
payment_data: Some(msgs::FinalOnionHopData {
15412
15426
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15413
15427
}),
15414
- sender_custom_tlvs: Vec::new(),
15428
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15415
15429
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height);
15416
15430
15417
15431
// Should not return an error as this condition:
0 commit comments