@@ -902,16 +902,17 @@ struct ClaimablePayments {
902902impl ClaimablePayments {
903903 /// Moves a payment from [`Self::claimable_payments`] to [`Self::pending_claiming_payments`].
904904 ///
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
909908 /// [`Self::pending_claiming_payments`].
910909 ///
910+ /// If `custom_tlvs_known` is true, and a matching payment is found, it will always be moved.
911+ ///
911912 /// 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>(
913914 &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 ,
915916 ) -> Result<(Vec<ClaimableHTLC>, ClaimingPayment), Vec<ClaimableHTLC>>
916917 where L::Target: Logger, S::Target: NodeSigner,
917918 {
@@ -928,8 +929,12 @@ impl ClaimablePayments {
928929 }
929930 }
930931
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+ }
933938 }
934939
935940 let payment_id = payment.inbound_payment_id(inbound_payment_id_secret);
@@ -6765,16 +6770,7 @@ where
67656770 let (sources, claiming_payment) = {
67666771 let res = self.claimable_payments.lock().unwrap().begin_claiming_payment(
67676772 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,
67786774 );
67796775
67806776 match res {
0 commit comments