From fa6c0587e7de6ba1e9bd908f0ea4efbd3f827668 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Fri, 16 Aug 2024 11:26:44 -0500 Subject: [PATCH] Return a Result from verify_payment_id --- lightning/src/ln/channelmanager.rs | 2 +- lightning/src/offers/signer.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index c6645956b..303c0d59e 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -10900,7 +10900,7 @@ where match context { Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => { - if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) { + if let Ok(()) = signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) { self.abandon_payment_with_reason( payment_id, PaymentFailureReason::InvoiceRequestRejected, ); diff --git a/lightning/src/offers/signer.rs b/lightning/src/offers/signer.rs index 0aa51cd33..2ee54c588 100644 --- a/lightning/src/offers/signer.rs +++ b/lightning/src/offers/signer.rs @@ -410,6 +410,6 @@ pub(crate) fn hmac_for_payment_id( pub(crate) fn verify_payment_id( payment_id: PaymentId, hmac: Hmac, nonce: Nonce, expanded_key: &ExpandedKey, -) -> bool { - hmac_for_payment_id(payment_id, nonce, expanded_key) == hmac +) -> Result<(), ()> { + if hmac_for_payment_id(payment_id, nonce, expanded_key) == hmac { Ok(()) } else { Err(()) } } -- 2.39.5