@@ -193,8 +193,14 @@ pub enum PendingHTLCRouting {
193
193
///
194
194
/// For HTLCs received by LDK, this will ultimately be exposed in
195
195
/// [`Event::PaymentClaimable::onion_fields`] as
196
- /// [`RecipientOnionFields::custom_tlvs`].
197
- custom_tlvs: Vec<(u64, Vec<u8>)>,
196
+ /// [`RecipientOnionFields::sender_custom_tlvs`].
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_tlvs`].
203
+ user_custom_tlvs: 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
},
@@ -223,8 +229,13 @@ pub enum PendingHTLCRouting {
223
229
/// Custom TLVs which were set by the sender.
224
230
///
225
231
/// For HTLCs received by LDK, these will ultimately bubble back up as
226
- /// [`RecipientOnionFields::custom_tlvs`].
227
- custom_tlvs: Vec<(u64, Vec<u8>)>,
232
+ /// [`RecipientOnionFields::sender_custom_tlvs`].
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_tlvs`].
238
+ user_custom_tlvs: 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
@@ -939,10 +950,10 @@ impl ClaimablePayments {
939
950
}
940
951
}
941
952
942
- if let Some(RecipientOnionFields { custom_tlvs , .. }) = &payment.onion_fields {
943
- if !custom_tlvs_known && custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
953
+ if let Some(RecipientOnionFields { sender_custom_tlvs , .. }) = &payment.onion_fields {
954
+ if !custom_tlvs_known && sender_custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
944
955
log_info!(logger, "Rejecting payment with payment hash {} as we cannot accept payment with unknown even TLVs: {}",
945
- &payment_hash, log_iter!(custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
956
+ &payment_hash, log_iter!(sender_custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
946
957
return Err(payment.htlcs);
947
958
}
948
959
}
@@ -6051,25 +6062,26 @@ where
6051
6062
) = match routing {
6052
6063
PendingHTLCRouting::Receive {
6053
6064
payment_data, payment_metadata, payment_context,
6054
- incoming_cltv_expiry, phantom_shared_secret, custom_tlvs ,
6065
+ incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs, user_custom_tlvs ,
6055
6066
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, custom_tlvs };
6070
+ payment_metadata, sender_custom_tlvs, user_custom_tlvs };
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, custom_tlvs , requires_blinded_error: _,
6077
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_tlvs , requires_blinded_error: _,
6067
6078
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
- custom_tlvs,
6083
+ sender_custom_tlvs,
6084
+ user_custom_tlvs,
6073
6085
};
6074
6086
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
6075
6087
payment_data, None, None, onion_fields, has_recipient_created_payment_secret)
@@ -12385,18 +12397,20 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12385
12397
(1, phantom_shared_secret, option),
12386
12398
(2, incoming_cltv_expiry, required),
12387
12399
(3, payment_metadata, option),
12388
- (5, custom_tlvs , optional_vec),
12400
+ (5, sender_custom_tlvs , optional_vec),
12389
12401
(7, requires_blinded_error, (default_value, false)),
12390
12402
(9, payment_context, option),
12403
+ (11, user_custom_tlvs, optional_vec),
12391
12404
},
12392
12405
(2, ReceiveKeysend) => {
12393
12406
(0, payment_preimage, required),
12394
12407
(1, requires_blinded_error, (default_value, false)),
12395
12408
(2, incoming_cltv_expiry, required),
12396
12409
(3, payment_metadata, option),
12397
12410
(4, payment_data, option), // Added in 0.0.116
12398
- (5, custom_tlvs , optional_vec),
12411
+ (5, sender_custom_tlvs , optional_vec),
12399
12412
(7, has_recipient_created_payment_secret, (default_value, false)),
12413
+ (9, user_custom_tlvs, optional_vec),
12400
12414
},
12401
12415
);
12402
12416
@@ -15361,7 +15375,8 @@ mod tests {
15361
15375
payment_data: Some(msgs::FinalOnionHopData {
15362
15376
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15363
15377
}),
15364
- custom_tlvs: Vec::new(),
15378
+ sender_custom_tlvs: Vec::new(),
15379
+ user_custom_tlvs: Vec::new(),
15365
15380
};
15366
15381
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15367
15382
// intended amount, we fail the payment.
@@ -15383,7 +15398,8 @@ mod tests {
15383
15398
payment_data: Some(msgs::FinalOnionHopData {
15384
15399
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15385
15400
}),
15386
- custom_tlvs: Vec::new(),
15401
+ sender_custom_tlvs: Vec::new(),
15402
+ user_custom_tlvs: Vec::new(),
15387
15403
};
15388
15404
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15389
15405
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15407,7 +15423,8 @@ mod tests {
15407
15423
payment_data: Some(msgs::FinalOnionHopData {
15408
15424
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15409
15425
}),
15410
- custom_tlvs: Vec::new(),
15426
+ sender_custom_tlvs: Vec::new(),
15427
+ user_custom_tlvs: Vec::new(),
15411
15428
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height);
15412
15429
15413
15430
// Should not return an error as this condition:
0 commit comments