Skip to content

Commit 03d4eb5

Browse files
committed
Use [u8; 32] rather than Hmac<Sha256> for simplicity
Mapping an `Hmac<Sha256>` 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.
1 parent 020b479 commit 03d4eb5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub enum OffersContext {
334334
/// used with an [`InvoiceError`].
335335
///
336336
/// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError
337-
hmac: Option<Hmac<Sha256>>,
337+
hmac: Option<[u8; 32]>,
338338
},
339339
/// Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`].
340340
///

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9081,7 +9081,7 @@ where
90819081
let invoice_request = builder.build_and_sign()?;
90829082

90839083
let hmac = payment_id.hmac_for_offer_payment(nonce, expanded_key);
9084-
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) };
9084+
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac.to_byte_array()) };
90859085
let reply_paths = self.create_blinded_paths(context)
90869086
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
90879087

@@ -10956,7 +10956,7 @@ where
1095610956

1095710957
match context {
1095810958
Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
10959-
if let Ok(()) = payment_id.verify(hmac, nonce, expanded_key) {
10959+
if let Ok(()) = payment_id.verify(bitcoin::hashes::hmac::Hmac::from_byte_array(hmac), nonce, expanded_key) {
1096010960
self.abandon_payment_with_reason(
1096110961
payment_id, PaymentFailureReason::InvoiceRequestRejected,
1096210962
);

0 commit comments

Comments
 (0)