From: Matt Corallo Date: Mon, 26 Aug 2024 18:28:50 +0000 (+0000) Subject: Use `[u8; 32]` rather than `Hmac` for simplicity X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=03d4eb52edbdfa7c8ead6329f34ee1f3587a0da4;p=rust-lightning Use `[u8; 32]` rather than `Hmac` for simplicity Mapping an `Hmac` would require somewhat custom logic as we'd have to behave differently based on generic parameters, so its simplest to just swap it to a `[u8; 32]` instead. --- diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs index e3899b50e..065187775 100644 --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@ -334,7 +334,7 @@ pub enum OffersContext { /// used with an [`InvoiceError`]. /// /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError - hmac: Option>, + hmac: Option<[u8; 32]>, }, /// Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`]. /// diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index eccffa5d3..cc84185e1 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -9081,7 +9081,7 @@ where let invoice_request = builder.build_and_sign()?; let hmac = payment_id.hmac_for_offer_payment(nonce, expanded_key); - let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }; + let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac.to_byte_array()) }; let reply_paths = self.create_blinded_paths(context) .map_err(|_| Bolt12SemanticError::MissingPaths)?; @@ -10956,7 +10956,7 @@ where match context { Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => { - if let Ok(()) = payment_id.verify(hmac, nonce, expanded_key) { + if let Ok(()) = payment_id.verify(bitcoin::hashes::hmac::Hmac::from_byte_array(hmac), nonce, expanded_key) { self.abandon_payment_with_reason( payment_id, PaymentFailureReason::InvoiceRequestRejected, );