Return a Result from verify_payment_id

This commit is contained in:
Jeffrey Czyz 2024-08-16 11:26:44 -05:00
parent 33e69958e0
commit fa6c0587e7
No known key found for this signature in database
GPG key ID: 912EF12EA67705F5
2 changed files with 3 additions and 3 deletions

View 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,
);

View 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(()) }
}