]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Pass full message context into ChanMan blinded path util.
authorValentine Wallace <vwallace@protonmail.com>
Wed, 10 Jul 2024 18:58:11 +0000 (14:58 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Fri, 13 Sep 2024 14:40:05 +0000 (10:40 -0400)
Allows us to repurpose this util to create blinded paths in an async payments
message context while maintaining support for the offers context.

lightning/src/ln/channelmanager.rs

index d88bf2c4cf23c931f8ce1aabbeaff64aadea7839..c6cffaf1023ac15f54bb8e6691d417e0d64d2d39 100644 (file)
@@ -9131,7 +9131,9 @@ where
                let invoice_request = builder.build_and_sign()?;
 
                let hmac = payment_id.hmac_for_offer_payment(nonce, expanded_key);
-               let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) };
+               let context = MessageContext::Offers(
+                       OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }
+               );
                let reply_paths = self.create_blinded_paths(context)
                        .map_err(|_| Bolt12SemanticError::MissingPaths)?;
 
@@ -9251,9 +9253,9 @@ where
 
                                let nonce = Nonce::from_entropy_source(entropy);
                                let hmac = payment_hash.hmac_for_offer_payment(nonce, expanded_key);
-                               let context = OffersContext::InboundPayment {
+                               let context = MessageContext::Offers(OffersContext::InboundPayment {
                                        payment_hash: invoice.payment_hash(), nonce, hmac
-                               };
+                               });
                                let reply_paths = self.create_blinded_paths(context)
                                        .map_err(|_| Bolt12SemanticError::MissingPaths)?;
 
@@ -9401,7 +9403,7 @@ where
                if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry {
                        self.create_compact_blinded_paths(context)
                } else {
-                       self.create_blinded_paths(context)
+                       self.create_blinded_paths(MessageContext::Offers(context))
                }
        }
 
@@ -9422,7 +9424,7 @@ where
        /// [`MessageRouter::create_blinded_paths`].
        ///
        /// Errors if the `MessageRouter` errors.
-       fn create_blinded_paths(&self, context: OffersContext) -> Result<Vec<BlindedMessagePath>, ()> {
+       fn create_blinded_paths(&self, context: MessageContext) -> Result<Vec<BlindedMessagePath>, ()> {
                let recipient = self.get_our_node_id();
                let secp_ctx = &self.secp_ctx;
 
@@ -9435,7 +9437,7 @@ where
                        .collect::<Vec<_>>();
 
                self.router
-                       .create_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
+                       .create_blinded_paths(recipient, context, peers, secp_ctx)
                        .and_then(|paths| (!paths.is_empty()).then(|| paths).ok_or(()))
        }
 
@@ -10839,11 +10841,11 @@ where
                {
                        let RetryableInvoiceRequest { invoice_request, nonce } = retryable_invoice_request;
                        let hmac = payment_id.hmac_for_offer_payment(nonce, &self.inbound_payment_key);
-                       let context = OffersContext::OutboundPayment {
+                       let context = MessageContext::Offers(OffersContext::OutboundPayment {
                                payment_id,
                                nonce,
                                hmac: Some(hmac)
-                       };
+                       });
                        match self.create_blinded_paths(context) {
                                Ok(reply_paths) => match self.enqueue_invoice_request(invoice_request, reply_paths) {
                                        Ok(_) => {}