@@ -547,24 +547,6 @@ pub trait Verification {
547547	) -> Result<(), ()>;
548548}
549549
550- impl Verification for PaymentHash {
551- 	/// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
552- 	/// along with the given [`Nonce`].
553- 	fn hmac_for_offer_payment(
554- 		&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
555- 	) -> Hmac<Sha256> {
556- 		signer::hmac_for_payment_hash(*self, nonce, expanded_key)
557- 	}
558- 
559- 	/// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
560- 	/// [`OffersContext::InboundPayment`].
561- 	fn verify_for_offer_payment(
562- 		&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
563- 	) -> Result<(), ()> {
564- 		signer::verify_payment_hash(*self, hmac, nonce, expanded_key)
565- 	}
566- }
567- 
568550impl Verification for UnauthenticatedReceiveTlvs {
569551	fn hmac_for_offer_payment(
570552		&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
@@ -589,42 +571,6 @@ pub struct PaymentId(pub [u8; Self::LENGTH]);
589571impl PaymentId {
590572	/// Number of bytes in the id.
591573	pub const LENGTH: usize = 32;
592- 
593- 	/// Constructs an HMAC to include in [`AsyncPaymentsContext::OutboundPayment`] for the payment id
594- 	/// along with the given [`Nonce`].
595- 	#[cfg(async_payments)]
596- 	pub fn hmac_for_async_payment(
597- 		&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
598- 	) -> Hmac<Sha256> {
599- 		signer::hmac_for_async_payment_id(*self, nonce, expanded_key)
600- 	}
601- 
602- 	/// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
603- 	/// [`AsyncPaymentsContext::OutboundPayment`].
604- 	#[cfg(async_payments)]
605- 	pub fn verify_for_async_payment(
606- 		&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
607- 	) -> Result<(), ()> {
608- 		signer::verify_async_payment_id(*self, hmac, nonce, expanded_key)
609- 	}
610- }
611- 
612- impl Verification for PaymentId {
613- 	/// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
614- 	/// along with the given [`Nonce`].
615- 	fn hmac_for_offer_payment(
616- 		&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
617- 	) -> Hmac<Sha256> {
618- 		signer::hmac_for_offer_payment_id(*self, nonce, expanded_key)
619- 	}
620- 
621- 	/// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
622- 	/// [`OffersContext::OutboundPayment`].
623- 	fn verify_for_offer_payment(
624- 		&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
625- 	) -> Result<(), ()> {
626- 		signer::verify_offer_payment_id(*self, hmac, nonce, expanded_key)
627- 	}
628574}
629575
630576impl PaymentId {
@@ -5291,10 +5237,7 @@ where
52915237				},
52925238			};
52935239
5294- 			let entropy = &*self.entropy_source;
5295- 
52965240			let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5297- 				entropy,
52985241				invoice,
52995242				payment_id,
53005243				self.get_peers_for_blinded_path(),
@@ -11824,7 +11767,7 @@ where
1182411767
1182511768				let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
1182611769
11827- 				self.flow.enqueue_invoice(entropy,  invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11770+ 				self.flow.enqueue_invoice(invoice.clone(), refund, self.get_peers_for_blinded_path())?;
1182811771
1182911772				Ok(invoice)
1183011773			},
@@ -13825,8 +13768,6 @@ where
1382513768	fn handle_message(
1382613769		&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
1382713770	) -> Option<(OffersMessage, ResponseInstruction)> {
13828- 		let expanded_key = &self.inbound_payment_key;
13829- 
1383013771		macro_rules! handle_pay_invoice_res {
1383113772			($res: expr, $invoice: expr, $logger: expr) => {{
1383213773				let error = match $res {
@@ -13942,38 +13883,26 @@ where
1394213883			#[cfg(async_payments)]
1394313884			OffersMessage::StaticInvoice(invoice) => {
1394413885				let payment_id = match context {
13945- 					Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13946- 						if payment_id.verify_for_offer_payment(hmac, nonce, expanded_key).is_err() {
13947- 							return None
13948- 						}
13949- 						payment_id
13950- 					},
13886+ 					Some(OffersContext::OutboundPayment { payment_id, .. }) => payment_id,
1395113887					_ => return None
1395213888				};
1395313889				let res = self.initiate_async_payment(&invoice, payment_id);
1395413890				handle_pay_invoice_res!(res, invoice, self.logger);
1395513891			},
1395613892			OffersMessage::InvoiceError(invoice_error) => {
1395713893				let payment_hash = match context {
13958- 					Some(OffersContext::InboundPayment { payment_hash, nonce, hmac }) => {
13959- 						match payment_hash.verify_for_offer_payment(hmac, nonce, expanded_key) {
13960- 							Ok(_) => Some(payment_hash),
13961- 							Err(_) => None,
13962- 						}
13963- 					},
13894+ 					Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
1396413895					_ => None,
1396513896				};
1396613897
1396713898				let logger = WithContext::from(&self.logger, None, None, payment_hash);
1396813899				log_trace!(logger, "Received invoice_error: {}", invoice_error);
1396913900
1397013901				match context {
13971- 					Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13972- 						if let Ok(()) = payment_id.verify_for_offer_payment(hmac, nonce, expanded_key) {
13973- 							self.abandon_payment_with_reason(
13974- 								payment_id, PaymentFailureReason::InvoiceRequestRejected,
13975- 							);
13976- 						}
13902+ 					Some(OffersContext::OutboundPayment { payment_id, .. }) => {
13903+ 						self.abandon_payment_with_reason(
13904+ 							payment_id, PaymentFailureReason::InvoiceRequestRejected,
13905+ 						);
1397713906					},
1397813907					_ => {},
1397913908				}
@@ -14122,15 +14051,18 @@ where
1412214051	fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
1412314052		#[cfg(async_payments)]
1412414053		{
14125- 			if let Ok(payment_id) = self.flow.verify_outbound_async_payment_context(_context) {
14126- 				if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
14127- 					log_trace!(
14128- 						self.logger,
14129- 						"Failed to release held HTLC with payment id {}: {:?}",
14130- 						payment_id,
14131- 						e
14132- 					);
14133- 				}
14054+ 			let payment_id = match _context {
14055+ 				AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
14056+ 				_ => return,
14057+ 			};
14058+ 
14059+ 			if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
14060+ 				log_trace!(
14061+ 					self.logger,
14062+ 					"Failed to release held HTLC with payment id {}: {:?}",
14063+ 					payment_id,
14064+ 					e
14065+ 				);
1413414066			}
1413514067		}
1413614068	}
0 commit comments