@@ -902,16 +902,17 @@ struct ClaimablePayments {
902
902
impl ClaimablePayments {
903
903
/// Moves a payment from [`Self::claimable_payments`] to [`Self::pending_claiming_payments`].
904
904
///
905
- /// The `check_onion` callback allows the caller to reject the payment based on the
906
- /// [`RecipientOnionFields`] (if any). If it returns `Err(_)`, the set of pending HTLCs will
907
- /// be returned in the `Err` variant of this method. They MUST then be failed by the caller as
908
- /// they will not be in either [`Self::claimable_payments`] or
905
+ /// If `custom_tlvs_known` is false and custom even TLVs are set by the sender, the set of
906
+ /// pending HTLCs will be returned in the `Err` variant of this method. They MUST then be
907
+ /// failed by the caller as they will not be in either [`Self::claimable_payments`] or
909
908
/// [`Self::pending_claiming_payments`].
910
909
///
910
+ /// If `custom_tlvs_known` is true, and a matching payment is found, it will always be moved.
911
+ ///
911
912
/// If no payment is found, `Err(Vec::new())` is returned.
912
- fn begin_claiming_payment<CheckOnion: Fn(&Option<RecipientOnionFields>) -> Result<(), ()>, L: Deref, S: Deref>(
913
+ fn begin_claiming_payment<L: Deref, S: Deref>(
913
914
&mut self, payment_hash: PaymentHash, node_signer: &S, logger: &L,
914
- inbound_payment_id_secret: &[u8; 32], check_onion: CheckOnion ,
915
+ inbound_payment_id_secret: &[u8; 32], custom_tlvs_known: bool ,
915
916
) -> Result<(Vec<ClaimableHTLC>, ClaimingPayment), Vec<ClaimableHTLC>>
916
917
where L::Target: Logger, S::Target: NodeSigner,
917
918
{
@@ -928,8 +929,12 @@ impl ClaimablePayments {
928
929
}
929
930
}
930
931
931
- if check_onion(&payment.onion_fields).is_err() {
932
- return Err(payment.htlcs);
932
+ if let Some(RecipientOnionFields { custom_tlvs, .. }) = &payment.onion_fields {
933
+ if !custom_tlvs_known && custom_tlvs.iter().any(|(typ, _)| typ % 2 == 0) {
934
+ 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)));
936
+ return Err(payment.htlcs);
937
+ }
933
938
}
934
939
935
940
let payment_id = payment.inbound_payment_id(inbound_payment_id_secret);
@@ -6765,16 +6770,7 @@ where
6765
6770
let (sources, claiming_payment) = {
6766
6771
let res = self.claimable_payments.lock().unwrap().begin_claiming_payment(
6767
6772
payment_hash, &self.node_signer, &self.logger, &self.inbound_payment_id_secret,
6768
- |onion_fields| {
6769
- if let Some(RecipientOnionFields { ref custom_tlvs, .. }) = onion_fields {
6770
- if !custom_tlvs_known && custom_tlvs.iter().any(|(typ, _)| typ % 2 == 0) {
6771
- log_info!(self.logger, "Rejecting payment with payment hash {} as we cannot accept payment with unknown even TLVs: {}",
6772
- &payment_hash, log_iter!(custom_tlvs.iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
6773
- return Err(());
6774
- }
6775
- }
6776
- Ok(())
6777
- }
6773
+ custom_tlvs_known,
6778
6774
);
6779
6775
6780
6776
match res {
0 commit comments