@@ -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)
@@ -12338,18 +12343,20 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12338
12343
(1, phantom_shared_secret, option),
12339
12344
(2, incoming_cltv_expiry, required),
12340
12345
(3, payment_metadata, option),
12341
- (5, custom_tlvs , optional_vec),
12346
+ (5, sender_custom_tlvs , optional_vec),
12342
12347
(7, requires_blinded_error, (default_value, false)),
12343
12348
(9, payment_context, option),
12349
+ (11, user_custom_tlvs, optional_vec),
12344
12350
},
12345
12351
(2, ReceiveKeysend) => {
12346
12352
(0, payment_preimage, required),
12347
12353
(1, requires_blinded_error, (default_value, false)),
12348
12354
(2, incoming_cltv_expiry, required),
12349
12355
(3, payment_metadata, option),
12350
12356
(4, payment_data, option), // Added in 0.0.116
12351
- (5, custom_tlvs , optional_vec),
12357
+ (5, sender_custom_tlvs , optional_vec),
12352
12358
(7, has_recipient_created_payment_secret, (default_value, false)),
12359
+ (9, user_custom_tlvs, optional_vec),
12353
12360
},
12354
12361
);
12355
12362
@@ -15344,7 +15351,8 @@ mod tests {
15344
15351
payment_data: Some(msgs::FinalOnionHopData {
15345
15352
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15346
15353
}),
15347
- custom_tlvs: Vec::new(),
15354
+ sender_custom_tlvs: Vec::new(),
15355
+ user_custom_tlvs: Vec::new(),
15348
15356
};
15349
15357
// Check that if the amount we received + the penultimate hop extra fee is less than the sender
15350
15358
// intended amount, we fail the payment.
@@ -15366,7 +15374,8 @@ mod tests {
15366
15374
payment_data: Some(msgs::FinalOnionHopData {
15367
15375
payment_secret: PaymentSecret([0; 32]), total_msat: sender_intended_amt_msat,
15368
15376
}),
15369
- custom_tlvs: Vec::new(),
15377
+ sender_custom_tlvs: Vec::new(),
15378
+ user_custom_tlvs: Vec::new(),
15370
15379
};
15371
15380
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
15372
15381
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
@@ -15390,7 +15399,8 @@ mod tests {
15390
15399
payment_data: Some(msgs::FinalOnionHopData {
15391
15400
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
15392
15401
}),
15393
- custom_tlvs: Vec::new(),
15402
+ sender_custom_tlvs: Vec::new(),
15403
+ user_custom_tlvs: Vec::new(),
15394
15404
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height,
15395
15405
node[0].node.default_configuration.accept_mpp_keysend);
15396
15406
0 commit comments