@@ -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
},
@@ -5712,23 +5716,24 @@ where
5712
5716
let (cltv_expiry, onion_payload, payment_data, payment_context, phantom_shared_secret, mut onion_fields) = match routing {
5713
5717
PendingHTLCRouting::Receive {
5714
5718
payment_data, payment_metadata, payment_context,
5715
- incoming_cltv_expiry, phantom_shared_secret, custom_tlvs ,
5719
+ incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs, user_custom_tlvs ,
5716
5720
requires_blinded_error: _
5717
5721
} => {
5718
5722
let _legacy_hop_data = Some(payment_data.clone());
5719
5723
let onion_fields = RecipientOnionFields { payment_secret: Some(payment_data.payment_secret),
5720
- payment_metadata, custom_tlvs };
5724
+ payment_metadata, sender_custom_tlvs, user_custom_tlvs };
5721
5725
(incoming_cltv_expiry, OnionPayload::Invoice { _legacy_hop_data },
5722
5726
Some(payment_data), payment_context, phantom_shared_secret, onion_fields)
5723
5727
},
5724
5728
PendingHTLCRouting::ReceiveKeysend {
5725
5729
payment_data, payment_preimage, payment_metadata,
5726
- incoming_cltv_expiry, custom_tlvs , requires_blinded_error: _
5730
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_tlvs , requires_blinded_error: _
5727
5731
} => {
5728
5732
let onion_fields = RecipientOnionFields {
5729
5733
payment_secret: payment_data.as_ref().map(|data| data.payment_secret),
5730
5734
payment_metadata,
5731
- custom_tlvs,
5735
+ sender_custom_tlvs,
5736
+ user_custom_tlvs,
5732
5737
};
5733
5738
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
5734
5739
payment_data, None, None, onion_fields)
@@ -6700,10 +6705,10 @@ where
6700
6705
}
6701
6706
});
6702
6707
6703
- if let Some(RecipientOnionFields { ref custom_tlvs , .. }) = claiming_payment.onion_fields {
6704
- if !custom_tlvs_known && custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
6708
+ if let Some(RecipientOnionFields { ref sender_custom_tlvs , .. }) = claiming_payment.onion_fields {
6709
+ if !custom_tlvs_known && sender_custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
6705
6710
log_info!(self.logger, "Rejecting payment with payment hash {} as we cannot accept payment with unknown even TLVs: {}",
6706
- &payment_hash, log_iter!(custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
6711
+ &payment_hash, log_iter!(sender_custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
6707
6712
claimable_payments.pending_claiming_payments.remove(&payment_hash);
6708
6713
mem::drop(claimable_payments);
6709
6714
for htlc in payment.htlcs {
@@ -11455,17 +11460,19 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
11455
11460
(1, phantom_shared_secret, option),
11456
11461
(2, incoming_cltv_expiry, required),
11457
11462
(3, payment_metadata, option),
11458
- (5, custom_tlvs , optional_vec),
11463
+ (5, sender_custom_tlvs , optional_vec),
11459
11464
(7, requires_blinded_error, (default_value, false)),
11460
11465
(9, payment_context, option),
11466
+ (11, user_custom_tlvs, optional_vec),
11461
11467
},
11462
11468
(2, ReceiveKeysend) => {
11463
11469
(0, payment_preimage, required),
11464
11470
(1, requires_blinded_error, (default_value, false)),
11465
11471
(2, incoming_cltv_expiry, required),
11466
11472
(3, payment_metadata, option),
11467
11473
(4, payment_data, option), // Added in 0.0.116
11468
- (5, custom_tlvs, optional_vec),
11474
+ (5, sender_custom_tlvs, optional_vec),
11475
+ (7, user_custom_tlvs, optional_vec),
11469
11476
},
11470
11477
);
11471
11478
@@ -14182,7 +14189,8 @@ mod tests {
14182
14189
payment_data: Some(msgs::FinalOnionHopData {
14183
14190
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
14184
14191
}),
14185
- custom_tlvs: Vec::new(),
14192
+ sender_custom_tlvs: Vec::new(),
14193
+ user_custom_tlvs: Vec::new(),
14186
14194
};
14187
14195
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
14188
14196
// intended amount, we fail the payment.
@@ -14204,7 +14212,8 @@ mod tests {
14204
14212
payment_data: Some(msgs::FinalOnionHopData {
14205
14213
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
14206
14214
}),
14207
- custom_tlvs: Vec::new(),
14215
+ sender_custom_tlvs: Vec::new(),
14216
+ user_custom_tlvs: Vec::new(),
14208
14217
};
14209
14218
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
14210
14219
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -14228,7 +14237,8 @@ mod tests {
14228
14237
payment_data: Some(msgs::FinalOnionHopData {
14229
14238
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
14230
14239
}),
14231
- custom_tlvs: Vec::new(),
14240
+ sender_custom_tlvs: Vec::new(),
14241
+ user_custom_tlvs: Vec::new(),
14232
14242
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height,
14233
14243
node[0].node.default_configuration.accept_mpp_keysend);
14234
14244
0 commit comments