@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
33
33
use bitcoin::{secp256k1, Sequence, Weight};
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<(), ()> {
@@ -4382,35 +4394,6 @@ where
4382
4394
self.pending_outbound_payments.test_set_payment_metadata(payment_id, new_payment_metadata);
4383
4395
}
4384
4396
4385
- /// Pays the [`Bolt12Invoice`] associated with the `payment_id` encoded in its `payer_metadata`.
4386
- ///
4387
- /// The invoice's `payer_metadata` is used to authenticate that the invoice was indeed requested
4388
- /// before attempting a payment. [`Bolt12PaymentError::UnexpectedInvoice`] is returned if this
4389
- /// fails or if the encoded `payment_id` is not recognized. The latter may happen once the
4390
- /// payment is no longer tracked because the payment was attempted after:
4391
- /// - an invoice for the `payment_id` was already paid,
4392
- /// - one full [timer tick] has elapsed since initially requesting the invoice when paying an
4393
- /// offer, or
4394
- /// - the refund corresponding to the invoice has already expired.
4395
- ///
4396
- /// To retry the payment, request another invoice using a new `payment_id`.
4397
- ///
4398
- /// Attempting to pay the same invoice twice while the first payment is still pending will
4399
- /// result in a [`Bolt12PaymentError::DuplicateInvoice`].
4400
- ///
4401
- /// Otherwise, either [`Event::PaymentSent`] or [`Event::PaymentFailed`] are used to indicate
4402
- /// whether or not the payment was successful.
4403
- ///
4404
- /// [timer tick]: Self::timer_tick_occurred
4405
- pub fn send_payment_for_bolt12_invoice(
4406
- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
4407
- ) -> Result<(), Bolt12PaymentError> {
4408
- match self.verify_bolt12_invoice(invoice, context) {
4409
- Ok(payment_id) => self.send_payment_for_verified_bolt12_invoice(invoice, payment_id),
4410
- Err(()) => Err(Bolt12PaymentError::UnexpectedInvoice),
4411
- }
4412
- }
4413
-
4414
4397
#[cfg(async_payments)]
4415
4398
fn initiate_async_payment(
4416
4399
&self, invoice: &StaticInvoice, payment_id: PaymentId
@@ -9537,27 +9520,11 @@ where
9537
9520
.collect::<Vec<_>>()
9538
9521
}
9539
9522
9540
- fn verify_bolt12_invoice(
9541
- &self, invoice: &Bolt12Invoice, context: Option<&OffersContext>,
9542
- ) -> Result<PaymentId, ()> {
9543
- let secp_ctx = &self.secp_ctx;
9544
- let expanded_key = &self.inbound_payment_key;
9545
-
9546
- match context {
9547
- None if invoice.is_for_refund_without_paths() => {
9548
- invoice.verify_using_metadata(expanded_key, secp_ctx)
9549
- },
9550
- Some(&OffersContext::OutboundPayment { payment_id, nonce, .. }) => {
9551
- invoice.verify_using_payer_data(payment_id, nonce, expanded_key, secp_ctx)
9552
- },
9553
- _ => Err(()),
9554
- }
9555
- }
9556
-
9557
9523
fn send_payment_for_verified_bolt12_invoice(&self, invoice: &Bolt12Invoice, payment_id: PaymentId) -> Result<(), Bolt12PaymentError> {
9558
9524
let best_block_height = self.best_block.read().unwrap().height;
9559
- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9560
9525
let features = self.bolt12_invoice_features();
9526
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
9527
+
9561
9528
self.pending_outbound_payments
9562
9529
.send_payment_for_bolt12_invoice(
9563
9530
invoice, payment_id, &self.router, self.list_usable_channels(), features,
0 commit comments