@@ -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 {
@@ -5302,10 +5248,7 @@ where
5302
5248
},
5303
5249
};
5304
5250
5305
- let entropy = &*self.entropy_source;
5306
-
5307
5251
let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5308
- entropy,
5309
5252
invoice,
5310
5253
payment_id,
5311
5254
self.get_peers_for_blinded_path(),
@@ -11297,7 +11240,7 @@ where
11297
11240
11298
11241
let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
11299
11242
11300
- self.flow.enqueue_invoice(entropy, invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11243
+ self.flow.enqueue_invoice(invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11301
11244
11302
11245
Ok(invoice)
11303
11246
},
@@ -13276,8 +13219,6 @@ where
13276
13219
fn handle_message(
13277
13220
&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
13278
13221
) -> Option<(OffersMessage, ResponseInstruction)> {
13279
- let expanded_key = &self.inbound_payment_key;
13280
-
13281
13222
macro_rules! handle_pay_invoice_res {
13282
13223
($res: expr, $invoice: expr, $logger: expr) => {{
13283
13224
let error = match $res {
@@ -13383,38 +13324,26 @@ where
13383
13324
#[cfg(async_payments)]
13384
13325
OffersMessage::StaticInvoice(invoice) => {
13385
13326
let payment_id = match context {
13386
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13387
- if payment_id.verify_for_offer_payment(hmac, nonce, expanded_key).is_err() {
13388
- return None
13389
- }
13390
- payment_id
13391
- },
13327
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => payment_id,
13392
13328
_ => return None
13393
13329
};
13394
13330
let res = self.initiate_async_payment(&invoice, payment_id);
13395
13331
handle_pay_invoice_res!(res, invoice, self.logger);
13396
13332
},
13397
13333
OffersMessage::InvoiceError(invoice_error) => {
13398
13334
let payment_hash = match context {
13399
- Some(OffersContext::InboundPayment { payment_hash, nonce, hmac }) => {
13400
- match payment_hash.verify_for_offer_payment(hmac, nonce, expanded_key) {
13401
- Ok(_) => Some(payment_hash),
13402
- Err(_) => None,
13403
- }
13404
- },
13335
+ Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
13405
13336
_ => None,
13406
13337
};
13407
13338
13408
13339
let logger = WithContext::from(&self.logger, None, None, payment_hash);
13409
13340
log_trace!(logger, "Received invoice_error: {}", invoice_error);
13410
13341
13411
13342
match context {
13412
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13413
- if let Ok(()) = payment_id.verify_for_offer_payment(hmac, nonce, expanded_key) {
13414
- self.abandon_payment_with_reason(
13415
- payment_id, PaymentFailureReason::InvoiceRequestRejected,
13416
- );
13417
- }
13343
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => {
13344
+ self.abandon_payment_with_reason(
13345
+ payment_id, PaymentFailureReason::InvoiceRequestRejected,
13346
+ );
13418
13347
},
13419
13348
_ => {},
13420
13349
}
@@ -13525,15 +13454,18 @@ where
13525
13454
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
13526
13455
#[cfg(async_payments)]
13527
13456
{
13528
- if let Ok(payment_id) = self.flow.verify_outbound_async_payment_context(_context) {
13529
- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
13530
- log_trace!(
13531
- self.logger,
13532
- "Failed to release held HTLC with payment id {}: {:?}",
13533
- payment_id,
13534
- e
13535
- );
13536
- }
13457
+ let payment_id = match _context {
13458
+ AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
13459
+ _ => return,
13460
+ };
13461
+
13462
+ if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
13463
+ log_trace!(
13464
+ self.logger,
13465
+ "Failed to release held HTLC with payment id {}: {:?}",
13466
+ payment_id,
13467
+ e
13468
+ );
13537
13469
}
13538
13470
}
13539
13471
}
0 commit comments