@@ -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};
@@ -438,11 +438,15 @@ impl Ord for ClaimableHTLC {
438438pub trait Verification {
439439 /// Constructs an HMAC to include in [`OffersContext`] for the data along with the given
440440 /// [`Nonce`].
441+ ///
442+ /// [`OffersContext`]: crate::blinded_path::message::OffersContext
441443 fn hmac_for_offer_payment(
442444 &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
443445 ) -> Hmac<Sha256>;
444446
445447 /// Authenticates the data using an HMAC and a [`Nonce`] taken from an [`OffersContext`].
448+ ///
449+ /// [`OffersContext`]: crate::blinded_path::message::OffersContext
446450 fn verify_for_offer_payment(
447451 &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
448452 ) -> Result<(), ()>;
@@ -451,6 +455,8 @@ pub trait Verification {
451455impl Verification for PaymentHash {
452456 /// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
453457 /// along with the given [`Nonce`].
458+ ///
459+ /// [`OffersContext::InboundPayment`]: crate::blinded_path::message::OffersContext::InboundPayment
454460 fn hmac_for_offer_payment(
455461 &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
456462 ) -> Hmac<Sha256> {
@@ -459,6 +465,8 @@ impl Verification for PaymentHash {
459465
460466 /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
461467 /// [`OffersContext::InboundPayment`].
468+ ///
469+ /// [`OffersContext::InboundPayment`]: crate::blinded_path::message::OffersContext::InboundPayment
462470 fn verify_for_offer_payment(
463471 &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
464472 ) -> Result<(), ()> {
@@ -499,6 +507,8 @@ impl PaymentId {
499507impl Verification for PaymentId {
500508 /// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
501509 /// along with the given [`Nonce`].
510+ ///
511+ /// [`OffersContext::OutboundPayment`]: crate::blinded_path::message::OffersContext::OutboundPayment
502512 fn hmac_for_offer_payment(
503513 &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
504514 ) -> Hmac<Sha256> {
@@ -507,6 +517,8 @@ impl Verification for PaymentId {
507517
508518 /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
509519 /// [`OffersContext::OutboundPayment`].
520+ ///
521+ /// [`OffersContext::OutboundPayment`]: crate::blinded_path::message::OffersContext::OutboundPayment
510522 fn verify_for_offer_payment(
511523 &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
512524 ) -> Result<(), ()> {
@@ -4376,35 +4388,6 @@ where
43764388 self.pending_outbound_payments.test_set_payment_metadata(payment_id, new_payment_metadata);
43774389 }
43784390
4379- /// Pays the [`Bolt12Invoice`] associated with the `payment_id` encoded in its `payer_metadata`.
4380- ///
4381- /// The invoice's `payer_metadata` is used to authenticate that the invoice was indeed requested
4382- /// before attempting a payment. [`Bolt12PaymentError::UnexpectedInvoice`] is returned if this
4383- /// fails or if the encoded `payment_id` is not recognized. The latter may happen once the
4384- /// payment is no longer tracked because the payment was attempted after:
4385- /// - an invoice for the `payment_id` was already paid,
4386- /// - one full [timer tick] has elapsed since initially requesting the invoice when paying an
4387- /// offer, or
4388- /// - the refund corresponding to the invoice has already expired.
4389- ///
4390- /// To retry the payment, request another invoice using a new `payment_id`.
4391- ///
4392- /// Attempting to pay the same invoice twice while the first payment is still pending will
4393- /// result in a [`Bolt12PaymentError::DuplicateInvoice`].
4394- ///
4395- /// Otherwise, either [`Event::PaymentSent`] or [`Event::PaymentFailed`] are used to indicate
4396- /// whether or not the payment was successful.
4397- ///
4398- /// [timer tick]: Self::timer_tick_occurred
4399- pub fn send_payment_for_bolt12_invoice(
4400- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
4401- ) -> Result<(), Bolt12PaymentError> {
4402- match self.verify_bolt12_invoice(invoice, context) {
4403- Ok(payment_id) => self.send_payment_for_verified_bolt12_invoice(invoice, payment_id),
4404- Err(()) => Err(Bolt12PaymentError::UnexpectedInvoice),
4405- }
4406- }
4407-
44084391 #[cfg(async_payments)]
44094392 fn initiate_async_payment(
44104393 &self, invoice: &StaticInvoice, payment_id: PaymentId
@@ -9528,15 +9511,10 @@ pub trait OffersMessageCommons {
95289511 /// Get the vector of peers that can be used for a blinded path
95299512 fn get_peer_for_blinded_path(&self) -> Vec<MessageForwardNode>;
95309513
9531- /// Verify bolt12 invoice
9532- fn verify_bolt12_invoice(
9533- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9534- ) -> Result<PaymentId, ()>;
9535-
95369514 /// Gets the current configuration applied to all new channels.
95379515 fn get_current_default_configuration(&self) -> &UserConfig;
95389516
9539- /// Send payment for verified bolt12 invoice
9517+ /// Send Payment for verified BOLT12 Invoice
95409518 fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError>;
95419519
95429520 /// Add new pending event
@@ -9658,31 +9636,15 @@ where
96589636 .collect::<Vec<_>>()
96599637 }
96609638
9661- fn verify_bolt12_invoice(
9662- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9663- ) -> Result<PaymentId, ()> {
9664- let secp_ctx = &self.secp_ctx;
9665- let expanded_key = &self.inbound_payment_key;
9666-
9667- match context {
9668- None if invoice.is_for_refund_without_paths() => {
9669- invoice.verify_using_metadata(expanded_key, secp_ctx)
9670- },
9671- Some(&OffersContext::OutboundPayment { payment_id, nonce, .. }) => {
9672- invoice.verify_using_payer_data(payment_id, nonce, expanded_key, secp_ctx)
9673- },
9674- _ => Err(()),
9675- }
9676- }
9677-
96789639 fn get_current_default_configuration(&self) -> &UserConfig {
96799640 &self.default_configuration
96809641 }
96819642
96829643 fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError> {
96839644 let best_block_height = self.best_block.read().unwrap().height;
9684- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
96859645 let features = self.bolt12_invoice_features();
9646+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9647+
96869648 self.pending_outbound_payments
96879649 .send_payment_for_bolt12_invoice(
96889650 invoice, payment_id, &self.router, self.list_usable_channels(), features,
0 commit comments