]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Return a Result from verify_payment_id
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 16 Aug 2024 16:26:44 +0000 (11:26 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 16 Aug 2024 16:31:31 +0000 (11:31 -0500)
lightning/src/ln/channelmanager.rs
lightning/src/offers/signer.rs

index c6645956b18decbcad3639f91f5db1f9015d7c61..303c0d59ea2307e954c5318b374ed4a37d95686f 100644 (file)
@@ -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,
                                                        );
index 0aa51cd3338232cc4a0646b4a0530c39bdf6cd79..2ee54c588119566cda8dc35e88874519a4d18c7c 100644 (file)
@@ -410,6 +410,6 @@ pub(crate) fn hmac_for_payment_id(
 
 pub(crate) fn verify_payment_id(
        payment_id: PaymentId, hmac: Hmac<Sha256>, 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(()) }
 }