@@ -187,7 +187,9 @@ pub enum PendingHTLCRouting {
187
187
/// For HTLCs received by LDK, this will ultimately be exposed in
188
188
/// [`Event::PaymentClaimable::onion_fields`] as
189
189
/// [`RecipientOnionFields::custom_tlvs`].
190
- custom_tlvs: Vec<(u64, Vec<u8>)>,
190
+ sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
191
+ /// Custom TLVs which were set by us through the reply path
192
+ user_custom_tlvs: Vec<u8>,
191
193
/// Set if this HTLC is the final hop in a multi-hop blinded path.
192
194
requires_blinded_error: bool,
193
195
},
@@ -217,7 +219,9 @@ pub enum PendingHTLCRouting {
217
219
///
218
220
/// For HTLCs received by LDK, these will ultimately bubble back up as
219
221
/// [`RecipientOnionFields::custom_tlvs`].
220
- custom_tlvs: Vec<(u64, Vec<u8>)>,
222
+ sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
223
+ /// Custom TLVs which were set by us through the reply path
224
+ user_custom_tlvs: Vec<u8>,
221
225
/// Set if this HTLC is the final hop in a multi-hop blinded path.
222
226
requires_blinded_error: bool,
223
227
},
@@ -929,10 +933,10 @@ impl ClaimablePayments {
929
933
}
930
934
}
931
935
932
- if let Some(RecipientOnionFields { custom_tlvs , .. }) = &payment.onion_fields {
933
- if !custom_tlvs_known && custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
936
+ if let Some(RecipientOnionFields { sender_custom_tlvs , .. }) = &payment.onion_fields {
937
+ if !custom_tlvs_known && sender_custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
934
938
log_info!(logger, "Rejecting payment with payment hash {} as we cannot accept payment with unknown even TLVs: {}",
935
- &payment_hash, log_iter!(custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
939
+ &payment_hash, log_iter!(sender_custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
936
940
return Err(payment.htlcs);
937
941
}
938
942
}
@@ -5839,23 +5843,24 @@ where
5839
5843
let (cltv_expiry, onion_payload, payment_data, payment_context, phantom_shared_secret, mut onion_fields) = match routing {
5840
5844
PendingHTLCRouting::Receive {
5841
5845
payment_data, payment_metadata, payment_context,
5842
- incoming_cltv_expiry, phantom_shared_secret, custom_tlvs ,
5846
+ incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs, user_custom_tlvs ,
5843
5847
requires_blinded_error: _
5844
5848
} => {
5845
5849
let _legacy_hop_data = Some(payment_data.clone());
5846
5850
let onion_fields = RecipientOnionFields { payment_secret: Some(payment_data.payment_secret),
5847
- payment_metadata, custom_tlvs };
5851
+ payment_metadata, sender_custom_tlvs, user_custom_tlvs };
5848
5852
(incoming_cltv_expiry, OnionPayload::Invoice { _legacy_hop_data },
5849
5853
Some(payment_data), payment_context, phantom_shared_secret, onion_fields)
5850
5854
},
5851
5855
PendingHTLCRouting::ReceiveKeysend {
5852
5856
payment_data, payment_preimage, payment_metadata,
5853
- incoming_cltv_expiry, custom_tlvs , requires_blinded_error: _
5857
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_tlvs , requires_blinded_error: _
5854
5858
} => {
5855
5859
let onion_fields = RecipientOnionFields {
5856
5860
payment_secret: payment_data.as_ref().map(|data| data.payment_secret),
5857
5861
payment_metadata,
5858
- custom_tlvs,
5862
+ sender_custom_tlvs,
5863
+ user_custom_tlvs,
5859
5864
};
5860
5865
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
5861
5866
payment_data, None, None, onion_fields)
@@ -11627,17 +11632,19 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
11627
11632
(1, phantom_shared_secret, option),
11628
11633
(2, incoming_cltv_expiry, required),
11629
11634
(3, payment_metadata, option),
11630
- (5, custom_tlvs , optional_vec),
11635
+ (5, sender_custom_tlvs , optional_vec),
11631
11636
(7, requires_blinded_error, (default_value, false)),
11632
11637
(9, payment_context, option),
11638
+ (11, user_custom_tlvs, optional_vec),
11633
11639
},
11634
11640
(2, ReceiveKeysend) => {
11635
11641
(0, payment_preimage, required),
11636
11642
(1, requires_blinded_error, (default_value, false)),
11637
11643
(2, incoming_cltv_expiry, required),
11638
11644
(3, payment_metadata, option),
11639
11645
(4, payment_data, option), // Added in 0.0.116
11640
- (5, custom_tlvs, optional_vec),
11646
+ (5, sender_custom_tlvs, optional_vec),
11647
+ (7, user_custom_tlvs, optional_vec),
11641
11648
},
11642
11649
);
11643
11650
@@ -14441,7 +14448,8 @@ mod tests {
14441
14448
payment_data: Some(msgs::FinalOnionHopData {
14442
14449
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
14443
14450
}),
14444
- custom_tlvs: Vec::new(),
14451
+ sender_custom_tlvs: Vec::new(),
14452
+ user_custom_tlvs: Vec::new(),
14445
14453
};
14446
14454
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
14447
14455
// intended amount, we fail the payment.
@@ -14463,7 +14471,8 @@ mod tests {
14463
14471
payment_data: Some(msgs::FinalOnionHopData {
14464
14472
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
14465
14473
}),
14466
- custom_tlvs: Vec::new(),
14474
+ sender_custom_tlvs: Vec::new(),
14475
+ user_custom_tlvs: Vec::new(),
14467
14476
};
14468
14477
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
14469
14478
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -14487,7 +14496,8 @@ mod tests {
14487
14496
payment_data: Some(msgs::FinalOnionHopData {
14488
14497
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
14489
14498
}),
14490
- custom_tlvs: Vec::new(),
14499
+ sender_custom_tlvs: Vec::new(),
14500
+ user_custom_tlvs: Vec::new(),
14491
14501
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height,
14492
14502
node[0].node.default_configuration.accept_mpp_keysend);
14493
14503
0 commit comments