@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
3333use bitcoin::{secp256k1, Sequence, Weight};
3434
3535use crate::events::FundingInfo;
36- use crate::blinded_path::message::{AsyncPaymentsContext, MessageContext, MessageForwardNode, OffersContext };
36+ use crate::blinded_path::message::{AsyncPaymentsContext, MessageContext, MessageForwardNode};
3737use crate::blinded_path::NodeIdLookUp;
3838use crate::blinded_path::message::BlindedMessagePath;
3939use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints, PaymentContext, ReceiveTlvs};
@@ -439,11 +439,15 @@ impl Ord for ClaimableHTLC {
439439pub trait Verification {
440440 /// Constructs an HMAC to include in [`OffersContext`] for the data along with the given
441441 /// [`Nonce`].
442+ ///
443+ /// [`OffersContext`]: crate::blinded_path::message::OffersContext
442444 fn hmac_for_offer_payment(
443445 &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
444446 ) -> Hmac<Sha256>;
445447
446448 /// Authenticates the data using an HMAC and a [`Nonce`] taken from an [`OffersContext`].
449+ ///
450+ /// [`OffersContext`]: crate::blinded_path::message::OffersContext
447451 fn verify_for_offer_payment(
448452 &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
449453 ) -> Result<(), ()>;
@@ -452,6 +456,8 @@ pub trait Verification {
452456impl Verification for PaymentHash {
453457 /// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
454458 /// along with the given [`Nonce`].
459+ ///
460+ /// [`OffersContext::InboundPayment`]: crate::blinded_path::message::OffersContext::InboundPayment
455461 fn hmac_for_offer_payment(
456462 &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
457463 ) -> Hmac<Sha256> {
@@ -460,6 +466,8 @@ impl Verification for PaymentHash {
460466
461467 /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
462468 /// [`OffersContext::InboundPayment`].
469+ ///
470+ /// [`OffersContext::InboundPayment`]: crate::blinded_path::message::OffersContext::InboundPayment
463471 fn verify_for_offer_payment(
464472 &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
465473 ) -> Result<(), ()> {
@@ -500,6 +508,8 @@ impl PaymentId {
500508impl Verification for PaymentId {
501509 /// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
502510 /// along with the given [`Nonce`].
511+ ///
512+ /// [`OffersContext::OutboundPayment`]: crate::blinded_path::message::OffersContext::OutboundPayment
503513 fn hmac_for_offer_payment(
504514 &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
505515 ) -> Hmac<Sha256> {
@@ -508,6 +518,8 @@ impl Verification for PaymentId {
508518
509519 /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
510520 /// [`OffersContext::OutboundPayment`].
521+ ///
522+ /// [`OffersContext::OutboundPayment`]: crate::blinded_path::message::OffersContext::OutboundPayment
511523 fn verify_for_offer_payment(
512524 &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
513525 ) -> Result<(), ()> {
@@ -4381,35 +4393,6 @@ where
43814393 self.pending_outbound_payments.test_set_payment_metadata(payment_id, new_payment_metadata);
43824394 }
43834395
4384- /// Pays the [`Bolt12Invoice`] associated with the `payment_id` encoded in its `payer_metadata`.
4385- ///
4386- /// The invoice's `payer_metadata` is used to authenticate that the invoice was indeed requested
4387- /// before attempting a payment. [`Bolt12PaymentError::UnexpectedInvoice`] is returned if this
4388- /// fails or if the encoded `payment_id` is not recognized. The latter may happen once the
4389- /// payment is no longer tracked because the payment was attempted after:
4390- /// - an invoice for the `payment_id` was already paid,
4391- /// - one full [timer tick] has elapsed since initially requesting the invoice when paying an
4392- /// offer, or
4393- /// - the refund corresponding to the invoice has already expired.
4394- ///
4395- /// To retry the payment, request another invoice using a new `payment_id`.
4396- ///
4397- /// Attempting to pay the same invoice twice while the first payment is still pending will
4398- /// result in a [`Bolt12PaymentError::DuplicateInvoice`].
4399- ///
4400- /// Otherwise, either [`Event::PaymentSent`] or [`Event::PaymentFailed`] are used to indicate
4401- /// whether or not the payment was successful.
4402- ///
4403- /// [timer tick]: Self::timer_tick_occurred
4404- pub fn send_payment_for_bolt12_invoice(
4405- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
4406- ) -> Result<(), Bolt12PaymentError> {
4407- match self.verify_bolt12_invoice(invoice, context) {
4408- Ok(payment_id) => self.send_payment_for_verified_bolt12_invoice(invoice, payment_id),
4409- Err(()) => Err(Bolt12PaymentError::UnexpectedInvoice),
4410- }
4411- }
4412-
44134396 #[cfg(async_payments)]
44144397 fn send_payment_for_static_invoice(
44154398 &self, payment_id: PaymentId
@@ -9472,27 +9455,11 @@ where
94729455 .collect::<Vec<_>>()
94739456 }
94749457
9475- fn verify_bolt12_invoice(
9476- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9477- ) -> Result<PaymentId, ()> {
9478- let secp_ctx = &self.secp_ctx;
9479- let expanded_key = &self.inbound_payment_key;
9480-
9481- match context {
9482- None if invoice.is_for_refund_without_paths() => {
9483- invoice.verify_using_metadata(expanded_key, secp_ctx)
9484- },
9485- Some(&OffersContext::OutboundPayment { payment_id, nonce, .. }) => {
9486- invoice.verify_using_payer_data(payment_id, nonce, expanded_key, secp_ctx)
9487- },
9488- _ => Err(()),
9489- }
9490- }
9491-
94929458 fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError> {
94939459 let best_block_height = self.best_block.read().unwrap().height;
9494- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
94959460 let features = self.bolt12_invoice_features();
9461+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9462+
94969463 self.pending_outbound_payments
94979464 .send_payment_for_bolt12_invoice(
94989465 invoice, payment_id, &self.router, self.list_usable_channels(), features,
0 commit comments