@@ -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)
@@ -12456,6 +12468,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12456
12468
(5, sender_custom_tlvs, optional_vec),
12457
12469
(7, requires_blinded_error, (default_value, false)),
12458
12470
(9, payment_context, option),
12471
+ (11, user_custom_data, optional_vec),
12459
12472
},
12460
12473
(2, ReceiveKeysend) => {
12461
12474
(0, payment_preimage, required),
@@ -12465,6 +12478,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12465
12478
(4, payment_data, option), // Added in 0.0.116
12466
12479
(5, sender_custom_tlvs, optional_vec),
12467
12480
(7, has_recipient_created_payment_secret, (default_value, false)),
12481
+ (9, user_custom_data, optional_vec),
12468
12482
},
12469
12483
);
12470
12484
@@ -15472,7 +15486,7 @@ mod tests {
15472
15486
payment_data: Some(msgs::FinalOnionHopData {
15473
15487
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15474
15488
}),
15475
- sender_custom_tlvs: Vec::new(),
15489
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15476
15490
};
15477
15491
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15478
15492
// intended amount, we fail the payment.
@@ -15494,7 +15508,7 @@ mod tests {
15494
15508
payment_data: Some(msgs::FinalOnionHopData {
15495
15509
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15496
15510
}),
15497
- sender_custom_tlvs: Vec::new(),
15511
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15498
15512
};
15499
15513
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15500
15514
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15518,7 +15532,7 @@ mod tests {
15518
15532
payment_data: Some(msgs::FinalOnionHopData {
15519
15533
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15520
15534
}),
15521
- sender_custom_tlvs: Vec::new(),
15535
+ sender_custom_tlvs: Vec::new(), user_custom_data: Vec::new(),
15522
15536
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height);
15523
15537
15524
15538
// Should not return an error as this condition:
0 commit comments