@@ -543,24 +543,6 @@ pub trait Verification {
543
543
) -> Result<(), ()>;
544
544
}
545
545
546
- impl Verification for PaymentHash {
547
- /// Constructs an HMAC to include in [`OffersContext::InboundPayment`] for the payment hash
548
- /// along with the given [`Nonce`].
549
- fn hmac_for_offer_payment(
550
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
551
- ) -> Hmac<Sha256> {
552
- signer::hmac_for_payment_hash(*self, nonce, expanded_key)
553
- }
554
-
555
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
556
- /// [`OffersContext::InboundPayment`].
557
- fn verify_for_offer_payment(
558
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
559
- ) -> Result<(), ()> {
560
- signer::verify_payment_hash(*self, hmac, nonce, expanded_key)
561
- }
562
- }
563
-
564
546
impl Verification for UnauthenticatedReceiveTlvs {
565
547
fn hmac_for_offer_payment(
566
548
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
@@ -585,42 +567,6 @@ pub struct PaymentId(pub [u8; Self::LENGTH]);
585
567
impl PaymentId {
586
568
/// Number of bytes in the id.
587
569
pub const LENGTH: usize = 32;
588
-
589
- /// Constructs an HMAC to include in [`AsyncPaymentsContext::OutboundPayment`] for the payment id
590
- /// along with the given [`Nonce`].
591
- #[cfg(async_payments)]
592
- pub fn hmac_for_async_payment(
593
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
594
- ) -> Hmac<Sha256> {
595
- signer::hmac_for_async_payment_id(*self, nonce, expanded_key)
596
- }
597
-
598
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
599
- /// [`AsyncPaymentsContext::OutboundPayment`].
600
- #[cfg(async_payments)]
601
- pub fn verify_for_async_payment(
602
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
603
- ) -> Result<(), ()> {
604
- signer::verify_async_payment_id(*self, hmac, nonce, expanded_key)
605
- }
606
- }
607
-
608
- impl Verification for PaymentId {
609
- /// Constructs an HMAC to include in [`OffersContext::OutboundPayment`] for the payment id
610
- /// along with the given [`Nonce`].
611
- fn hmac_for_offer_payment(
612
- &self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
613
- ) -> Hmac<Sha256> {
614
- signer::hmac_for_offer_payment_id(*self, nonce, expanded_key)
615
- }
616
-
617
- /// Authenticates the payment id using an HMAC and a [`Nonce`] taken from an
618
- /// [`OffersContext::OutboundPayment`].
619
- fn verify_for_offer_payment(
620
- &self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
621
- ) -> Result<(), ()> {
622
- signer::verify_offer_payment_id(*self, hmac, nonce, expanded_key)
623
- }
624
570
}
625
571
626
572
impl PaymentId {
@@ -5276,10 +5222,7 @@ where
5276
5222
},
5277
5223
};
5278
5224
5279
- let entropy = &*self.entropy_source;
5280
-
5281
5225
let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5282
- entropy,
5283
5226
invoice,
5284
5227
payment_id,
5285
5228
self.get_peers_for_blinded_path(),
@@ -11228,7 +11171,7 @@ where
11228
11171
11229
11172
let invoice = builder.allow_mpp().build_and_sign(secp_ctx)?;
11230
11173
11231
- self.flow.enqueue_invoice(entropy, invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11174
+ self.flow.enqueue_invoice(invoice.clone(), refund, self.get_peers_for_blinded_path())?;
11232
11175
11233
11176
Ok(invoice)
11234
11177
},
@@ -13199,8 +13142,6 @@ where
13199
13142
fn handle_message(
13200
13143
&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
13201
13144
) -> Option<(OffersMessage, ResponseInstruction)> {
13202
- let expanded_key = &self.inbound_payment_key;
13203
-
13204
13145
macro_rules! handle_pay_invoice_res {
13205
13146
($res: expr, $invoice: expr, $logger: expr) => {{
13206
13147
let error = match $res {
@@ -13306,38 +13247,26 @@ where
13306
13247
#[cfg(async_payments)]
13307
13248
OffersMessage::StaticInvoice(invoice) => {
13308
13249
let payment_id = match context {
13309
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13310
- if payment_id.verify_for_offer_payment(hmac, nonce, expanded_key).is_err() {
13311
- return None
13312
- }
13313
- payment_id
13314
- },
13250
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => payment_id,
13315
13251
_ => return None
13316
13252
};
13317
13253
let res = self.initiate_async_payment(&invoice, payment_id);
13318
13254
handle_pay_invoice_res!(res, invoice, self.logger);
13319
13255
},
13320
13256
OffersMessage::InvoiceError(invoice_error) => {
13321
13257
let payment_hash = match context {
13322
- Some(OffersContext::InboundPayment { payment_hash, nonce, hmac }) => {
13323
- match payment_hash.verify_for_offer_payment(hmac, nonce, expanded_key) {
13324
- Ok(_) => Some(payment_hash),
13325
- Err(_) => None,
13326
- }
13327
- },
13258
+ Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
13328
13259
_ => None,
13329
13260
};
13330
13261
13331
13262
let logger = WithContext::from(&self.logger, None, None, payment_hash);
13332
13263
log_trace!(logger, "Received invoice_error: {}", invoice_error);
13333
13264
13334
13265
match context {
13335
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
13336
- if let Ok(()) = payment_id.verify_for_offer_payment(hmac, nonce, expanded_key) {
13337
- self.abandon_payment_with_reason(
13338
- payment_id, PaymentFailureReason::InvoiceRequestRejected,
13339
- );
13340
- }
13266
+ Some(OffersContext::OutboundPayment { payment_id, .. }) => {
13267
+ self.abandon_payment_with_reason(
13268
+ payment_id, PaymentFailureReason::InvoiceRequestRejected,
13269
+ );
13341
13270
},
13342
13271
_ => {},
13343
13272
}
@@ -13390,15 +13319,18 @@ where
13390
13319
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
13391
13320
#[cfg(async_payments)]
13392
13321
{
13393
- if let Ok(payment_id) = self.flow.verify_outbound_async_payment_context(_context) {
13394
- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
13395
- log_trace!(
13396
- self.logger,
13397
- "Failed to release held HTLC with payment id {}: {:?}",
13398
- payment_id,
13399
- e
13400
- );
13401
- }
13322
+ let payment_id = match _context {
13323
+ AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
13324
+ _ => return,
13325
+ };
13326
+
13327
+ if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
13328
+ log_trace!(
13329
+ self.logger,
13330
+ "Failed to release held HTLC with payment id {}: {:?}",
13331
+ payment_id,
13332
+ e
13333
+ );
13402
13334
}
13403
13335
}
13404
13336
}
0 commit comments