@@ -545,24 +545,6 @@ pub trait Verification {
545
545
) -> Result<(), ()>;
546
546
}
547
547
548
- impl Verification for PaymentHash {
549
- /// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
550
- /// along with the given [`Nonce`].
551
- fn hmac_for_offer_payment(
552
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
553
- ) -> Hmac<Sha256> {
554
- signer::hmac_for_payment_hash(*self, nonce, expanded_key)
555
- }
556
-
557
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
558
- /// [`OffersContext::InboundPayment`].
559
- fn verify_for_offer_payment(
560
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
561
- ) -> Result<(), ()> {
562
- signer::verify_payment_hash(*self, hmac, nonce, expanded_key)
563
- }
564
- }
565
-
566
548
impl Verification for UnauthenticatedReceiveTlvs {
567
549
fn hmac_for_offer_payment(
568
550
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
@@ -587,42 +569,6 @@ pub struct PaymentId(pub [u8; Self::LENGTH]);
587
569
impl PaymentId {
588
570
/// Number of bytes in the id.
589
571
pub const LENGTH: usize = 32;
590
-
591
- /// Constructs an HMAC to include in [`AsyncPaymentsContext::OutboundPayment`] for the payment id
592
- /// along with the given [`Nonce`].
593
- #[cfg(async_payments)]
594
- pub fn hmac_for_async_payment(
595
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
596
- ) -> Hmac<Sha256> {
597
- signer::hmac_for_async_payment_id(*self, nonce, expanded_key)
598
- }
599
-
600
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
601
- /// [`AsyncPaymentsContext::OutboundPayment`].
602
- #[cfg(async_payments)]
603
- pub fn verify_for_async_payment(
604
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
605
- ) -> Result<(), ()> {
606
- signer::verify_async_payment_id(*self, hmac, nonce, expanded_key)
607
- }
608
- }
609
-
610
- impl Verification for PaymentId {
611
- /// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
612
- /// along with the given [`Nonce`].
613
- fn hmac_for_offer_payment(
614
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
615
- ) -> Hmac<Sha256> {
616
- signer::hmac_for_offer_payment_id(*self, nonce, expanded_key)
617
- }
618
-
619
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
620
- /// [`OffersContext::OutboundPayment`].
621
- fn verify_for_offer_payment(
622
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
623
- ) -> Result<(), ()> {
624
- signer::verify_offer_payment_id(*self, hmac, nonce, expanded_key)
625
- }
626
572
}
627
573
628
574
impl PaymentId {
@@ -5322,10 +5268,7 @@ where
5322
5268
},
5323
5269
};
5324
5270
5325
- let entropy = &*self.entropy_source;
5326
-
5327
5271
let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5328
- entropy,
5329
5272
invoice,
5330
5273
payment_id,
5331
5274
self.get_peers_for_blinded_path(),
@@ -11317,7 +11260,7 @@ where
11317
11260
11318
11261
let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
11319
11262
11320
- self.flow.enqueue_invoice(entropy, invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11263
+ self.flow.enqueue_invoice(invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11321
11264
11322
11265
Ok(invoice)
11323
11266
},
@@ -13324,8 +13267,6 @@ where
13324
13267
fn handle_message(
13325
13268
&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
13326
13269
) -> Option<(OffersMessage, ResponseInstruction)> {
13327
- let expanded_key = &self.inbound_payment_key;
13328
-
13329
13270
macro_rules! handle_pay_invoice_res {
13330
13271
($res: expr, $invoice: expr, $logger: expr) => {{
13331
13272
let error = match $res {
@@ -13441,38 +13382,26 @@ where
13441
13382
#[cfg(async_payments)]
13442
13383
OffersMessage::StaticInvoice(invoice) => {
13443
13384
let payment_id = match context {
13444
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13445
- if payment_id.verify_for_offer_payment(hmac, nonce, expanded_key).is_err() {
13446
- return None
13447
- }
13448
- payment_id
13449
- },
13385
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => payment_id,
13450
13386
_ => return None
13451
13387
};
13452
13388
let res = self.initiate_async_payment(&invoice, payment_id);
13453
13389
handle_pay_invoice_res!(res, invoice, self.logger);
13454
13390
},
13455
13391
OffersMessage::InvoiceError(invoice_error) => {
13456
13392
let payment_hash = match context {
13457
- Some(OffersContext::InboundPayment { payment_hash, nonce, hmac }) => {
13458
- match payment_hash.verify_for_offer_payment(hmac, nonce, expanded_key) {
13459
- Ok(_) => Some(payment_hash),
13460
- Err(_) => None,
13461
- }
13462
- },
13393
+ Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
13463
13394
_ => None,
13464
13395
};
13465
13396
13466
13397
let logger = WithContext::from(&self.logger, None, None, payment_hash);
13467
13398
log_trace!(logger, "Received invoice_error: {}", invoice_error);
13468
13399
13469
13400
match context {
13470
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13471
- if let Ok(()) = payment_id.verify_for_offer_payment(hmac, nonce, expanded_key) {
13472
- self.abandon_payment_with_reason(
13473
- payment_id, PaymentFailureReason::InvoiceRequestRejected,
13474
- );
13475
- }
13401
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => {
13402
+ self.abandon_payment_with_reason(
13403
+ payment_id, PaymentFailureReason::InvoiceRequestRejected,
13404
+ );
13476
13405
},
13477
13406
_ => {},
13478
13407
}
@@ -13621,15 +13550,18 @@ where
13621
13550
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
13622
13551
#[cfg(async_payments)]
13623
13552
{
13624
- if let Ok(payment_id) = self.flow.verify_outbound_async_payment_context(_context) {
13625
- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
13626
- log_trace!(
13627
- self.logger,
13628
- "Failed to release held HTLC with payment id {}: {:?}",
13629
- payment_id,
13630
- e
13631
- );
13632
- }
13553
+ let payment_id = match _context {
13554
+ AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
13555
+ _ => return,
13556
+ };
13557
+
13558
+ if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
13559
+ log_trace!(
13560
+ self.logger,
13561
+ "Failed to release held HTLC with payment id {}: {:?}",
13562
+ payment_id,
13563
+ e
13564
+ );
13633
13565
}
13634
13566
}
13635
13567
}
0 commit comments