@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
3333use bitcoin::{secp256k1, Sequence};
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<(), ()> {
@@ -1997,11 +2009,11 @@ where
19972009/// For details on initiating payments for offers, see [`pay_for_offer`].
19982010///
19992011/// ## BOLT 12 Refunds
2000- ///
2012+ ///
20012013/// For more information on creating refunds, see [`create_refund_builder`].
20022014///
20032015/// For requesting refund payments, see [`request_refund_payment`].
2004- ///
2016+ ///
20052017/// # Persistence
20062018///
20072019/// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
@@ -2572,7 +2584,7 @@ pub enum RecentPaymentDetails {
25722584 AwaitingInvoice {
25732585 /// A user-provided identifier in [`OffersMessageFlow::pay_for_offer`] used to uniquely identify a
25742586 /// payment and ensure idempotency in LDK.
2575- ///
2587+ ///
25762588 /// [`OffersMessageFlow::pay_for_offer`]: crate::offers::flow::OffersMessageFlow::pay_for_offer
25772589 payment_id: PaymentId,
25782590 },
@@ -4390,35 +4402,6 @@ where
43904402 self.pending_outbound_payments.test_set_payment_metadata(payment_id, new_payment_metadata);
43914403 }
43924404
4393- /// Pays the [`Bolt12Invoice`] associated with the `payment_id` encoded in its `payer_metadata`.
4394- ///
4395- /// The invoice's `payer_metadata` is used to authenticate that the invoice was indeed requested
4396- /// before attempting a payment. [`Bolt12PaymentError::UnexpectedInvoice`] is returned if this
4397- /// fails or if the encoded `payment_id` is not recognized. The latter may happen once the
4398- /// payment is no longer tracked because the payment was attempted after:
4399- /// - an invoice for the `payment_id` was already paid,
4400- /// - one full [timer tick] has elapsed since initially requesting the invoice when paying an
4401- /// offer, or
4402- /// - the refund corresponding to the invoice has already expired.
4403- ///
4404- /// To retry the payment, request another invoice using a new `payment_id`.
4405- ///
4406- /// Attempting to pay the same invoice twice while the first payment is still pending will
4407- /// result in a [`Bolt12PaymentError::DuplicateInvoice`].
4408- ///
4409- /// Otherwise, either [`Event::PaymentSent`] or [`Event::PaymentFailed`] are used to indicate
4410- /// whether or not the payment was successful.
4411- ///
4412- /// [timer tick]: Self::timer_tick_occurred
4413- pub fn send_payment_for_bolt12_invoice(
4414- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
4415- ) -> Result<(), Bolt12PaymentError> {
4416- match self.verify_bolt12_invoice(invoice, context) {
4417- Ok(payment_id) => self.send_payment_for_verified_bolt12_invoice(invoice, payment_id),
4418- Err(()) => Err(Bolt12PaymentError::UnexpectedInvoice),
4419- }
4420- }
4421-
44224405 #[cfg(async_payments)]
44234406 fn initiate_async_payment(
44244407 &self, invoice: &StaticInvoice, payment_id: PaymentId
@@ -9217,15 +9200,10 @@ pub trait OffersMessageCommons {
92179200 /// Get the vector of peers that can be used for a blinded path
92189201 fn get_peer_for_blinded_path(&self) -> Vec<MessageForwardNode>;
92199202
9220- /// Verify bolt12 invoice
9221- fn verify_bolt12_invoice(
9222- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9223- ) -> Result<PaymentId, ()>;
9224-
92259203 /// Gets the current configuration applied to all new channels.
92269204 fn get_current_default_configuration(&self) -> &UserConfig;
92279205
9228- /// Send payment for verified bolt12 invoice
9206+ /// Send Payment for verified BOLT12 Invoice
92299207 fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError>;
92309208
92319209 /// Add new pending event
@@ -9347,31 +9325,15 @@ where
93479325 .collect::<Vec<_>>()
93489326 }
93499327
9350- fn verify_bolt12_invoice(
9351- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9352- ) -> Result<PaymentId, ()> {
9353- let secp_ctx = &self.secp_ctx;
9354- let expanded_key = &self.inbound_payment_key;
9355-
9356- match context {
9357- None if invoice.is_for_refund_without_paths() => {
9358- invoice.verify_using_metadata(expanded_key, secp_ctx)
9359- },
9360- Some(&OffersContext::OutboundPayment { payment_id, nonce, .. }) => {
9361- invoice.verify_using_payer_data(payment_id, nonce, expanded_key, secp_ctx)
9362- },
9363- _ => Err(()),
9364- }
9365- }
9366-
93679328 fn get_current_default_configuration(&self) -> &UserConfig {
93689329 &self.default_configuration
93699330 }
93709331
93719332 fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError> {
93729333 let best_block_height = self.best_block.read().unwrap().height;
9373- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
93749334 let features = self.bolt12_invoice_features();
9335+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9336+
93759337 self.pending_outbound_payments
93769338 .send_payment_for_bolt12_invoice(
93779339 invoice, payment_id, &self.router, self.list_usable_channels(), features,
0 commit comments