From: Jeffrey Czyz Date: Fri, 16 Aug 2024 16:26:44 +0000 (-0500) Subject: Return a Result from verify_payment_id X-Git-Tag: v0.0.124-beta~8^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=fa6c0587e7de6ba1e9bd908f0ea4efbd3f827668;p=rust-lightning Return a Result from verify_payment_id --- 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(()) } }