@@ -195,7 +195,9 @@ pub enum PendingHTLCRouting {
195
195
/// For HTLCs received by LDK, this will ultimately be exposed in
196
196
/// [`Event::PaymentClaimable::onion_fields`] as
197
197
/// [`RecipientOnionFields::custom_tlvs`].
198
- custom_tlvs: Vec<(u64, Vec<u8>)>,
198
+ sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
199
+ /// Custom TLVs which were set by us through the reply path
200
+ user_custom_tlvs: Vec<u8>,
199
201
/// Set if this HTLC is the final hop in a multi-hop blinded path.
200
202
requires_blinded_error: bool,
201
203
},
@@ -225,7 +227,9 @@ pub enum PendingHTLCRouting {
225
227
///
226
228
/// For HTLCs received by LDK, these will ultimately bubble back up as
227
229
/// [`RecipientOnionFields::custom_tlvs`].
228
- custom_tlvs: Vec<(u64, Vec<u8>)>,
230
+ sender_custom_tlvs: Vec<(u64, Vec<u8>)>,
231
+ /// Custom TLVs which were set by us through the reply path
232
+ user_custom_tlvs: Vec<u8>,
229
233
/// Set if this HTLC is the final hop in a multi-hop blinded path.
230
234
requires_blinded_error: bool,
231
235
/// Set if we are receiving a keysend to a blinded path, meaning we created the
@@ -941,10 +945,10 @@ impl ClaimablePayments {
941
945
}
942
946
}
943
947
944
- if let Some(RecipientOnionFields { custom_tlvs , .. }) = &payment.onion_fields {
945
- if !custom_tlvs_known && custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
948
+ if let Some(RecipientOnionFields { sender_custom_tlvs , .. }) = &payment.onion_fields {
949
+ if !custom_tlvs_known && sender_custom_tlvs .iter().any(|(typ, _)| typ % 2 == 0) {
946
950
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)));
951
+ &payment_hash, log_iter!(sender_custom_tlvs .iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
948
952
return Err(payment.htlcs);
949
953
}
950
954
}
@@ -5985,25 +5989,26 @@ where
5985
5989
) = match routing {
5986
5990
PendingHTLCRouting::Receive {
5987
5991
payment_data, payment_metadata, payment_context,
5988
- incoming_cltv_expiry, phantom_shared_secret, custom_tlvs ,
5992
+ incoming_cltv_expiry, phantom_shared_secret, sender_custom_tlvs, user_custom_tlvs ,
5989
5993
requires_blinded_error: _
5990
5994
} => {
5991
5995
let _legacy_hop_data = Some(payment_data.clone());
5992
5996
let onion_fields = RecipientOnionFields { payment_secret: Some(payment_data.payment_secret),
5993
- payment_metadata, custom_tlvs };
5997
+ payment_metadata, sender_custom_tlvs, user_custom_tlvs };
5994
5998
(incoming_cltv_expiry, OnionPayload::Invoice { _legacy_hop_data },
5995
5999
Some(payment_data), payment_context, phantom_shared_secret, onion_fields,
5996
6000
true)
5997
6001
},
5998
6002
PendingHTLCRouting::ReceiveKeysend {
5999
6003
payment_data, payment_preimage, payment_metadata,
6000
- incoming_cltv_expiry, custom_tlvs , requires_blinded_error: _,
6004
+ incoming_cltv_expiry, sender_custom_tlvs, user_custom_tlvs , requires_blinded_error: _,
6001
6005
has_recipient_created_payment_secret,
6002
6006
} => {
6003
6007
let onion_fields = RecipientOnionFields {
6004
6008
payment_secret: payment_data.as_ref().map(|data| data.payment_secret),
6005
6009
payment_metadata,
6006
- custom_tlvs,
6010
+ sender_custom_tlvs,
6011
+ user_custom_tlvs,
6007
6012
};
6008
6013
(incoming_cltv_expiry, OnionPayload::Spontaneous(payment_preimage),
6009
6014
payment_data, None, None, onion_fields, has_recipient_created_payment_secret)
@@ -12348,18 +12353,20 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12348
12353
(1, phantom_shared_secret, option),
12349
12354
(2, incoming_cltv_expiry, required),
12350
12355
(3, payment_metadata, option),
12351
- (5, custom_tlvs , optional_vec),
12356
+ (5, sender_custom_tlvs , optional_vec),
12352
12357
(7, requires_blinded_error, (default_value, false)),
12353
12358
(9, payment_context, option),
12359
+ (11, user_custom_tlvs, optional_vec),
12354
12360
},
12355
12361
(2, ReceiveKeysend) => {
12356
12362
(0, payment_preimage, required),
12357
12363
(1, requires_blinded_error, (default_value, false)),
12358
12364
(2, incoming_cltv_expiry, required),
12359
12365
(3, payment_metadata, option),
12360
12366
(4, payment_data, option), // Added in 0.0.116
12361
- (5, custom_tlvs , optional_vec),
12367
+ (5, sender_custom_tlvs , optional_vec),
12362
12368
(7, has_recipient_created_payment_secret, (default_value, false)),
12369
+ (9, user_custom_tlvs, optional_vec),
12363
12370
},
12364
12371
);
12365
12372
@@ -15354,7 +15361,8 @@ mod tests {
15354
15361
payment_data: Some(msgs::FinalOnionHopData {
15355
15362
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15356
15363
}),
15357
- custom_tlvs: Vec::new(),
15364
+ sender_custom_tlvs: Vec::new(),
15365
+ user_custom_tlvs: Vec::new(),
15358
15366
};
15359
15367
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15360
15368
// intended amount, we fail the payment.
@@ -15376,7 +15384,8 @@ mod tests {
15376
15384
payment_data: Some(msgs::FinalOnionHopData {
15377
15385
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15378
15386
}),
15379
- custom_tlvs: Vec::new(),
15387
+ sender_custom_tlvs: Vec::new(),
15388
+ user_custom_tlvs: Vec::new(),
15380
15389
};
15381
15390
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15382
15391
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15400,7 +15409,8 @@ mod tests {
15400
15409
payment_data: Some(msgs::FinalOnionHopData {
15401
15410
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15402
15411
}),
15403
- custom_tlvs: Vec::new(),
15412
+ sender_custom_tlvs: Vec::new(),
15413
+ user_custom_tlvs: Vec::new(),
15404
15414
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height,
15405
15415
node[0].node.default_configuration.accept_mpp_keysend);
15406
15416
0 commit comments