#[allow(unused_imports)]
use crate::prelude::*;
+use bitcoin::hashes::hmac::Hmac;
+use bitcoin::hashes::sha256::Hash as Sha256;
use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode, NextMessageHop, NodeIdLookUp};
use crate::blinded_path::utils;
use crate::io;
/// [`Refund`]: crate::offers::refund::Refund
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
nonce: Nonce,
+
+ /// Authentication code for the [`PaymentId`], which should be checked when the context is
+ /// used with an [`InvoiceError`].
+ ///
+ /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError
+ hmac: Hmac<Sha256>,
},
/// Context used by a [`BlindedPath`] as a reply path for a [`Bolt12Invoice`].
///
(1, OutboundPayment) => {
(0, payment_id, required),
(1, nonce, required),
+ (2, hmac, required),
},
(2, InboundPayment) => {
(0, payment_hash, required),
use crate::offers::offer::{Offer, OfferBuilder};
use crate::offers::parse::Bolt12SemanticError;
use crate::offers::refund::{Refund, RefundBuilder};
+use crate::offers::signer;
use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
use crate::onion_message::messenger::{new_pending_onion_message, Destination, MessageRouter, PendingOnionMessage, Responder, ResponseInstruction};
use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
None if invoice.is_for_refund_without_paths() => {
invoice.verify_using_metadata(expanded_key, secp_ctx)
},
- Some(&OffersContext::OutboundPayment { payment_id, nonce }) => {
+ Some(&OffersContext::OutboundPayment { payment_id, nonce, .. }) => {
invoice.verify_using_payer_data(payment_id, nonce, expanded_key, secp_ctx)
},
_ => Err(()),
let secp_ctx = &$self.secp_ctx;
let nonce = Nonce::from_entropy_source(entropy);
- let context = OffersContext::OutboundPayment { payment_id, nonce };
+ let hmac = signer::hmac_for_payment_id(payment_id, nonce, expanded_key);
+ let context = OffersContext::OutboundPayment { payment_id, nonce, hmac };
let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry))
.and_then(|paths| paths.into_iter().next().ok_or(()))
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
};
let invoice_request = builder.build_and_sign()?;
- let context = OffersContext::OutboundPayment { payment_id, nonce };
+ let hmac = signer::hmac_for_payment_id(payment_id, nonce, expanded_key);
+ let context = OffersContext::OutboundPayment { payment_id, nonce, hmac };
let reply_paths = self.create_blinded_paths(context)
.map_err(|_| Bolt12SemanticError::MissingPaths)?;