@@ -194,8 +194,14 @@ pub enum PendingHTLCRouting {
194
194
///
195
195
/// For HTLCs received by LDK, this will ultimately be exposed in
196
196
/// [`Event::PaymentClaimable::onion_fields`] as
197
- /// [`RecipientOnionFields::custom_tlvs`].
198
- custom_tlvs: Vec<(u64, Vec<u8>)>,
197
+ /// [`RecipientOnionFields::sender_custom_tlvs`].
198
+ sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
199
+ /// Custom TLVs set by the receiver in the blinded path used to reach them.
200
+ ///
201
+ /// For HTLCs received by LDK, this will be exposed in
202
+ /// [`Event::PaymentClaimable::onion_fields`] as
203
+ /// [`RecipientOnionFields::user_custom_tlvs`].
204
+ user_custom_tlvs: Vec<u8>,
199
205
/// Set if this HTLC is the final hop in a multi-hop blinded path.
200
206
requires_blinded_error: bool,
201
207
},
@@ -224,8 +230,13 @@ pub enum PendingHTLCRouting {
224
230
/// Custom TLVs which were set by the sender.
225
231
///
226
232
/// For HTLCs received by LDK, these will ultimately bubble back up as
227
- /// [`RecipientOnionFields::custom_tlvs`].
228
- custom_tlvs: Vec<(u64, Vec<u8>)>,
233
+ /// [`RecipientOnionFields::sender_custom_tlvs`].
234
+ sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
235
+ /// Custom TLVs set by the receiver in the blinded path used to reach them.
236
+ ///
237
+ /// For HTLCs received by LDK, these will ultimately bubble back up as
238
+ /// [`RecipientOnionFields::user_custom_tlvs`].
239
+ user_custom_tlvs: Vec<u8>,
229
240
/// Set if this HTLC is the final hop in a multi-hop blinded path.
230
241
requires_blinded_error: bool,
231
242
/// Set if we are receiving a keysend to a blinded path, meaning we created the
@@ -941,10 +952,10 @@ impl ClaimablePayments {
941
952
}
942
953
}
943
954
944
- if let Some(RecipientOnionFields { custom_tlvs , .. }) = &payment.onion_fields {
945
- if !custom_tlvs_known && custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
955
+ if let Some(RecipientOnionFields { sender_custom_tlvs , .. }) = &payment.onion_fields {
956
+ if !custom_tlvs_known && sender_custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
946
957
log_info!(logger, "Rejecting payment with payment hash {} as we cannot accept payment with unknown even TLVs: {}",
947
- &payment_hash, log_iter!(custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
958
+ &payment_hash, log_iter!(sender_custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
948
959
return Err(payment.htlcs);
949
960
}
950
961
}
@@ -5985,25 +5996,26 @@ where
5985
5996
) = match routing {
5986
5997
PendingHTLCRouting::Receive {
5987
5998
payment_data, payment_metadata, payment_context,
5988
- incoming_cltv_expiry, phantom_shared_secret, custom_tlvs ,
5999
+ incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs, user_custom_tlvs ,
5989
6000
requires_blinded_error: _
5990
6001
} => {
5991
6002
let _legacy_hop_data = Some(payment_data.clone());
5992
6003
let onion_fields = RecipientOnionFields { payment_secret: Some(payment_data.payment_secret),
5993
- payment_metadata, custom_tlvs };
6004
+ payment_metadata, sender_custom_tlvs, user_custom_tlvs };
5994
6005
(incoming_cltv_expiry, OnionPayload::Invoice { _legacy_hop_data },
5995
6006
Some(payment_data), payment_context, phantom_shared_secret, onion_fields,
5996
6007
true)
5997
6008
},
5998
6009
PendingHTLCRouting::ReceiveKeysend {
5999
6010
payment_data, payment_preimage, payment_metadata,
6000
- incoming_cltv_expiry, custom_tlvs , requires_blinded_error: _,
6011
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_tlvs , requires_blinded_error: _,
6001
6012
has_recipient_created_payment_secret,
6002
6013
} => {
6003
6014
let onion_fields = RecipientOnionFields {
6004
6015
payment_secret: payment_data.as_ref().map(|data| data.payment_secret),
6005
6016
payment_metadata,
6006
- custom_tlvs,
6017
+ sender_custom_tlvs,
6018
+ user_custom_tlvs,
6007
6019
};
6008
6020
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
6009
6021
payment_data, None, None, onion_fields, has_recipient_created_payment_secret)
@@ -12348,18 +12360,20 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12348
12360
(1, phantom_shared_secret, option),
12349
12361
(2, incoming_cltv_expiry, required),
12350
12362
(3, payment_metadata, option),
12351
- (5, custom_tlvs , optional_vec),
12363
+ (5, sender_custom_tlvs , optional_vec),
12352
12364
(7, requires_blinded_error, (default_value, false)),
12353
12365
(9, payment_context, option),
12366
+ (11, user_custom_tlvs, optional_vec),
12354
12367
},
12355
12368
(2, ReceiveKeysend) => {
12356
12369
(0, payment_preimage, required),
12357
12370
(1, requires_blinded_error, (default_value, false)),
12358
12371
(2, incoming_cltv_expiry, required),
12359
12372
(3, payment_metadata, option),
12360
12373
(4, payment_data, option), // Added in 0.0.116
12361
- (5, custom_tlvs , optional_vec),
12374
+ (5, sender_custom_tlvs , optional_vec),
12362
12375
(7, has_recipient_created_payment_secret, (default_value, false)),
12376
+ (9, user_custom_tlvs, optional_vec),
12363
12377
},
12364
12378
);
12365
12379
@@ -15354,7 +15368,8 @@ mod tests {
15354
15368
payment_data: Some(msgs::FinalOnionHopData {
15355
15369
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15356
15370
}),
15357
- custom_tlvs: Vec::new(),
15371
+ sender_custom_tlvs: Vec::new(),
15372
+ user_custom_tlvs: Vec::new(),
15358
15373
};
15359
15374
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15360
15375
// intended amount, we fail the payment.
@@ -15376,7 +15391,8 @@ mod tests {
15376
15391
payment_data: Some(msgs::FinalOnionHopData {
15377
15392
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15378
15393
}),
15379
- custom_tlvs: Vec::new(),
15394
+ sender_custom_tlvs: Vec::new(),
15395
+ user_custom_tlvs: Vec::new(),
15380
15396
};
15381
15397
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15382
15398
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15400,7 +15416,8 @@ mod tests {
15400
15416
payment_data: Some(msgs::FinalOnionHopData {
15401
15417
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15402
15418
}),
15403
- custom_tlvs: Vec::new(),
15419
+ sender_custom_tlvs: Vec::new(),
15420
+ user_custom_tlvs: Vec::new(),
15404
15421
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height,
15405
15422
node[0].node.default_configuration.accept_mpp_keysend);
15406
15423
0 commit comments