@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
33
33
use bitcoin::{secp256k1, Sequence};
34
34
35
35
use crate::events::FundingInfo;
36
- use crate::blinded_path::message::{AsyncPaymentsContext, MessageContext, MessageForwardNode, OffersContext };
36
+ use crate::blinded_path::message::{AsyncPaymentsContext, MessageContext, MessageForwardNode};
37
37
use crate::blinded_path::NodeIdLookUp;
38
38
use crate::blinded_path::message::BlindedMessagePath;
39
39
use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints, PaymentContext, ReceiveTlvs};
@@ -439,11 +439,15 @@ impl Ord for ClaimableHTLC {
439
439
pub trait Verification {
440
440
/// Constructs an HMAC to include in [`OffersContext`] for the data along with the given
441
441
/// [`Nonce`].
442
+ ///
443
+ /// [`OffersContext`]: crate::blinded_path::message::OffersContext
442
444
fn hmac_for_offer_payment(
443
445
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
444
446
) -> Hmac<Sha256>;
445
447
446
448
/// Authenticates the data using an HMAC and a [`Nonce`] taken from an [`OffersContext`].
449
+ ///
450
+ /// [`OffersContext`]: crate::blinded_path::message::OffersContext
447
451
fn verify_for_offer_payment(
448
452
&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
449
453
) -> Result<(), ()>;
@@ -452,6 +456,8 @@ pub trait Verification {
452
456
impl Verification for PaymentHash {
453
457
/// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
454
458
/// along with the given [`Nonce`].
459
+ ///
460
+ /// [`OffersContext::InboundPayment`]: crate::blinded_path::message::OffersContext::InboundPayment
455
461
fn hmac_for_offer_payment(
456
462
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
457
463
) -> Hmac<Sha256> {
@@ -460,6 +466,8 @@ impl Verification for PaymentHash {
460
466
461
467
/// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
462
468
/// [`OffersContext::InboundPayment`].
469
+ ///
470
+ /// [`OffersContext::InboundPayment`]: crate::blinded_path::message::OffersContext::InboundPayment
463
471
fn verify_for_offer_payment(
464
472
&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
465
473
) -> Result<(), ()> {
@@ -500,6 +508,8 @@ impl PaymentId {
500
508
impl Verification for PaymentId {
501
509
/// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
502
510
/// along with the given [`Nonce`].
511
+ ///
512
+ /// [`OffersContext::OutboundPayment`]: crate::blinded_path::message::OffersContext::OutboundPayment
503
513
fn hmac_for_offer_payment(
504
514
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
505
515
) -> Hmac<Sha256> {
@@ -508,6 +518,8 @@ impl Verification for PaymentId {
508
518
509
519
/// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
510
520
/// [`OffersContext::OutboundPayment`].
521
+ ///
522
+ /// [`OffersContext::OutboundPayment`]: crate::blinded_path::message::OffersContext::OutboundPayment
511
523
fn verify_for_offer_payment(
512
524
&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
513
525
) -> Result<(), ()> {
@@ -1997,11 +2009,11 @@ where
1997
2009
/// For details on initiating payments for offers, see [`pay_for_offer`].
1998
2010
///
1999
2011
/// ## BOLT 12 Refunds
2000
- ///
2012
+ ///
2001
2013
/// For more information on creating refunds, see [`create_refund_builder`].
2002
2014
///
2003
2015
/// For requesting refund payments, see [`request_refund_payment`].
2004
- ///
2016
+ ///
2005
2017
/// # Persistence
2006
2018
///
2007
2019
/// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
@@ -2572,7 +2584,7 @@ pub enum RecentPaymentDetails {
2572
2584
AwaitingInvoice {
2573
2585
/// A user-provided identifier in [`OffersMessageFlow::pay_for_offer`] used to uniquely identify a
2574
2586
/// payment and ensure idempotency in LDK.
2575
- ///
2587
+ ///
2576
2588
/// [`OffersMessageFlow::pay_for_offer`]: crate::offers::flow::OffersMessageFlow::pay_for_offer
2577
2589
payment_id: PaymentId,
2578
2590
},
@@ -4390,35 +4402,6 @@ where
4390
4402
self.pending_outbound_payments.test_set_payment_metadata(payment_id, new_payment_metadata);
4391
4403
}
4392
4404
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
-
4422
4405
#[cfg(async_payments)]
4423
4406
fn initiate_async_payment(
4424
4407
&self, invoice: &StaticInvoice, payment_id: PaymentId
@@ -9217,15 +9200,10 @@ pub trait OffersMessageCommons {
9217
9200
/// Get the vector of peers that can be used for a blinded path
9218
9201
fn get_peer_for_blinded_path(&self) -> Vec<MessageForwardNode>;
9219
9202
9220
- /// Verify bolt12 invoice
9221
- fn verify_bolt12_invoice(
9222
- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9223
- ) -> Result<PaymentId, ()>;
9224
-
9225
9203
/// Gets the current configuration applied to all new channels.
9226
9204
fn get_current_default_configuration(&self) -> &UserConfig;
9227
9205
9228
- /// Send payment for verified bolt12 invoice
9206
+ /// Send Payment for verified BOLT12 Invoice
9229
9207
fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError>;
9230
9208
9231
9209
/// Add new pending event
@@ -9347,31 +9325,15 @@ where
9347
9325
.collect::<Vec<_>>()
9348
9326
}
9349
9327
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
-
9367
9328
fn get_current_default_configuration(&self) -> &UserConfig {
9368
9329
&self.default_configuration
9369
9330
}
9370
9331
9371
9332
fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError> {
9372
9333
let best_block_height = self.best_block.read().unwrap().height;
9373
- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9374
9334
let features = self.bolt12_invoice_features();
9335
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9336
+
9375
9337
self.pending_outbound_payments
9376
9338
.send_payment_for_bolt12_invoice(
9377
9339
invoice, payment_id, &self.router, self.list_usable_channels(), features,
0 commit comments