@@ -204,6 +204,12 @@ pub enum PendingHTLCRouting {
204
204
/// [`Event::PaymentClaimable::onion_fields`] as
205
205
/// [`RecipientOnionFields::sender_custom_tlvs`].
206
206
sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
207
+ /// Custom TLVs set by the receiver in the blinded path used to reach them.
208
+ ///
209
+ /// For HTLCs received by LDK, this will be exposed in
210
+ /// [`Event::PaymentClaimable::onion_fields`] as
211
+ /// [`RecipientOnionFields::user_custom_data`].
212
+ user_custom_data: Vec<u8>,
207
213
/// Set if this HTLC is the final hop in a multi-hop blinded path.
208
214
requires_blinded_error: bool,
209
215
},
@@ -234,6 +240,11 @@ pub enum PendingHTLCRouting {
234
240
/// For HTLCs received by LDK, these will ultimately bubble back up as
235
241
/// [`RecipientOnionFields::sender_custom_tlvs`].
236
242
sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
243
+ /// Custom TLVs set by the receiver in the blinded path used to reach them.
244
+ ///
245
+ /// For HTLCs received by LDK, these will ultimately bubble back up as
246
+ /// [`RecipientOnionFields::user_custom_data`].
247
+ user_custom_data: Vec<u8>,
237
248
/// Set if this HTLC is the final hop in a multi-hop blinded path.
238
249
requires_blinded_error: bool,
239
250
/// Set if we are receiving a keysend to a blinded path, meaning we created the
@@ -6039,24 +6050,25 @@ where
6039
6050
PendingHTLCRouting::Receive {
6040
6051
payment_data, payment_metadata, payment_context,
6041
6052
incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs,
6042
- requires_blinded_error: _
6053
+ user_custom_data, requires_blinded_error: _
6043
6054
} => {
6044
6055
let _legacy_hop_data = Some(payment_data.clone());
6045
6056
let onion_fields = RecipientOnionFields { payment_secret: Some(payment_data.payment_secret),
6046
- payment_metadata, sender_custom_tlvs };
6057
+ payment_metadata, sender_custom_tlvs, user_custom_data };
6047
6058
(incoming_cltv_expiry, OnionPayload::Invoice { _legacy_hop_data },
6048
6059
Some(payment_data), payment_context, phantom_shared_secret, onion_fields,
6049
6060
true)
6050
6061
},
6051
6062
PendingHTLCRouting::ReceiveKeysend {
6052
6063
payment_data, payment_preimage, payment_metadata,
6053
- incoming_cltv_expiry, sender_custom_tlvs, requires_blinded_error: _ ,
6054
- has_recipient_created_payment_secret,
6064
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_data ,
6065
+ requires_blinded_error: _, has_recipient_created_payment_secret,
6055
6066
} => {
6056
6067
let onion_fields = RecipientOnionFields {
6057
6068
payment_secret: payment_data.as_ref().map(|data| data.payment_secret),
6058
6069
payment_metadata,
6059
6070
sender_custom_tlvs,
6071
+ user_custom_data
6060
6072
};
6061
6073
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
6062
6074
payment_data, None, None, onion_fields, has_recipient_created_payment_secret)
@@ -12453,6 +12465,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12453
12465
(5, sender_custom_tlvs, optional_vec),
12454
12466
(7, requires_blinded_error, (default_value, false)),
12455
12467
(9, payment_context, option),
12468
+ (11, user_custom_data, optional_vec),
12456
12469
},
12457
12470
(2, ReceiveKeysend) => {
12458
12471
(0, payment_preimage, required),
@@ -12462,6 +12475,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12462
12475
(4, payment_data, option), // Added in 0.0.116
12463
12476
(5, sender_custom_tlvs, optional_vec),
12464
12477
(7, has_recipient_created_payment_secret, (default_value, false)),
12478
+ (9, user_custom_data, optional_vec),
12465
12479
},
12466
12480
);
12467
12481
@@ -15469,7 +15483,7 @@ mod tests {
15469
15483
payment_data: Some(msgs::FinalOnionHopData {
15470
15484
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15471
15485
}),
15472
- sender_custom_tlvs: Vec::new(),
15486
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15473
15487
};
15474
15488
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15475
15489
// intended amount, we fail the payment.
@@ -15491,7 +15505,7 @@ mod tests {
15491
15505
payment_data: Some(msgs::FinalOnionHopData {
15492
15506
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15493
15507
}),
15494
- sender_custom_tlvs: Vec::new(),
15508
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15495
15509
};
15496
15510
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15497
15511
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15515,7 +15529,7 @@ mod tests {
15515
15529
payment_data: Some(msgs::FinalOnionHopData {
15516
15530
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15517
15531
}),
15518
- sender_custom_tlvs: Vec::new(),
15532
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15519
15533
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height);
15520
15534
15521
15535
// Should not return an error as this condition:
0 commit comments