@@ -547,24 +547,6 @@ pub trait Verification {
547
547
) -> Result<(), ()>;
548
548
}
549
549
550
- impl Verification for PaymentHash {
551
- /// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
552
- /// along with the given [`Nonce`].
553
- fn hmac_for_offer_payment(
554
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
555
- ) -> Hmac<Sha256> {
556
- signer::hmac_for_payment_hash(*self, nonce, expanded_key)
557
- }
558
-
559
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
560
- /// [`OffersContext::InboundPayment`].
561
- fn verify_for_offer_payment(
562
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
563
- ) -> Result<(), ()> {
564
- signer::verify_payment_hash(*self, hmac, nonce, expanded_key)
565
- }
566
- }
567
-
568
550
impl Verification for UnauthenticatedReceiveTlvs {
569
551
fn hmac_for_offer_payment(
570
552
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
@@ -589,42 +571,6 @@ pub struct PaymentId(pub [u8; Self::LENGTH]);
589
571
impl PaymentId {
590
572
/// Number of bytes in the id.
591
573
pub const LENGTH: usize = 32;
592
-
593
- /// Constructs an HMAC to include in [`AsyncPaymentsContext::OutboundPayment`] for the payment id
594
- /// along with the given [`Nonce`].
595
- #[cfg(async_payments)]
596
- pub fn hmac_for_async_payment(
597
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
598
- ) -> Hmac<Sha256> {
599
- signer::hmac_for_async_payment_id(*self, nonce, expanded_key)
600
- }
601
-
602
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
603
- /// [`AsyncPaymentsContext::OutboundPayment`].
604
- #[cfg(async_payments)]
605
- pub fn verify_for_async_payment(
606
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
607
- ) -> Result<(), ()> {
608
- signer::verify_async_payment_id(*self, hmac, nonce, expanded_key)
609
- }
610
- }
611
-
612
- impl Verification for PaymentId {
613
- /// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
614
- /// along with the given [`Nonce`].
615
- fn hmac_for_offer_payment(
616
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
617
- ) -> Hmac<Sha256> {
618
- signer::hmac_for_offer_payment_id(*self, nonce, expanded_key)
619
- }
620
-
621
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
622
- /// [`OffersContext::OutboundPayment`].
623
- fn verify_for_offer_payment(
624
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
625
- ) -> Result<(), ()> {
626
- signer::verify_offer_payment_id(*self, hmac, nonce, expanded_key)
627
- }
628
574
}
629
575
630
576
impl PaymentId {
@@ -5291,10 +5237,7 @@ where
5291
5237
},
5292
5238
};
5293
5239
5294
- let entropy = &*self.entropy_source;
5295
-
5296
5240
let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5297
- entropy,
5298
5241
invoice,
5299
5242
payment_id,
5300
5243
self.get_peers_for_blinded_path(),
@@ -11824,7 +11767,7 @@ where
11824
11767
11825
11768
let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
11826
11769
11827
- self.flow.enqueue_invoice(entropy, invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11770
+ self.flow.enqueue_invoice(invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11828
11771
11829
11772
Ok(invoice)
11830
11773
},
@@ -13825,8 +13768,6 @@ where
13825
13768
fn handle_message(
13826
13769
&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
13827
13770
) -> Option<(OffersMessage, ResponseInstruction)> {
13828
- let expanded_key = &self.inbound_payment_key;
13829
-
13830
13771
macro_rules! handle_pay_invoice_res {
13831
13772
($res: expr, $invoice: expr, $logger: expr) => {{
13832
13773
let error = match $res {
@@ -13942,38 +13883,26 @@ where
13942
13883
#[cfg(async_payments)]
13943
13884
OffersMessage::StaticInvoice(invoice) => {
13944
13885
let payment_id = match context {
13945
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13946
- if payment_id.verify_for_offer_payment(hmac, nonce, expanded_key).is_err() {
13947
- return None
13948
- }
13949
- payment_id
13950
- },
13886
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => payment_id,
13951
13887
_ => return None
13952
13888
};
13953
13889
let res = self.initiate_async_payment(&invoice, payment_id);
13954
13890
handle_pay_invoice_res!(res, invoice, self.logger);
13955
13891
},
13956
13892
OffersMessage::InvoiceError(invoice_error) => {
13957
13893
let payment_hash = match context {
13958
- Some(OffersContext::InboundPayment { payment_hash, nonce, hmac }) => {
13959
- match payment_hash.verify_for_offer_payment(hmac, nonce, expanded_key) {
13960
- Ok(_) => Some(payment_hash),
13961
- Err(_) => None,
13962
- }
13963
- },
13894
+ Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
13964
13895
_ => None,
13965
13896
};
13966
13897
13967
13898
let logger = WithContext::from(&self.logger, None, None, payment_hash);
13968
13899
log_trace!(logger, "Received invoice_error: {}", invoice_error);
13969
13900
13970
13901
match context {
13971
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13972
- if let Ok(()) = payment_id.verify_for_offer_payment(hmac, nonce, expanded_key) {
13973
- self.abandon_payment_with_reason(
13974
- payment_id, PaymentFailureReason::InvoiceRequestRejected,
13975
- );
13976
- }
13902
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => {
13903
+ self.abandon_payment_with_reason(
13904
+ payment_id, PaymentFailureReason::InvoiceRequestRejected,
13905
+ );
13977
13906
},
13978
13907
_ => {},
13979
13908
}
@@ -14122,15 +14051,18 @@ where
14122
14051
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
14123
14052
#[cfg(async_payments)]
14124
14053
{
14125
- if let Ok(payment_id) = self.flow.verify_outbound_async_payment_context(_context) {
14126
- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
14127
- log_trace!(
14128
- self.logger,
14129
- "Failed to release held HTLC with payment id {}: {:?}",
14130
- payment_id,
14131
- e
14132
- );
14133
- }
14054
+ let payment_id = match _context {
14055
+ AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
14056
+ _ => return,
14057
+ };
14058
+
14059
+ if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
14060
+ log_trace!(
14061
+ self.logger,
14062
+ "Failed to release held HTLC with payment id {}: {:?}",
14063
+ payment_id,
14064
+ e
14065
+ );
14134
14066
}
14135
14067
}
14136
14068
}
0 commit comments