]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add reply_path to BOLT12Invoices in Offers Flow
authorshaavan <shaavan.github@gmail.com>
Fri, 6 Sep 2024 12:21:37 +0000 (17:51 +0530)
committershaavan <shaavan.github@gmail.com>
Wed, 11 Sep 2024 13:24:49 +0000 (18:54 +0530)
1. Introduced reply_path in BOLT12Invoices to address a gap in error handling.
   Previously, if a BOLT12Invoice sent in the offers flow generated an Invoice Error,
   the payer had no way to send this error back to the payee.
2. By adding a reply_path to the Invoice Message, the payer can now communicate
   any errors back to the payee, ensuring better error handling and communication
   within the offers flow.

lightning/src/ln/channelmanager.rs

index c8597f8f0354fa44f40d9ea52e48d2f197df4ed6..993a320d187b6a6fb70a431b6180fbfd5823b632 100644 (file)
@@ -10927,7 +10927,12 @@ where
                                };
 
                                match response {
-                                       Ok(invoice) => Some((OffersMessage::Invoice(invoice), responder.respond())),
+                                       Ok(invoice) => {
+                                               let nonce = Nonce::from_entropy_source(&*self.entropy_source);
+                                               let hmac = payment_hash.hmac_for_offer_payment(nonce, expanded_key);
+                                               let context = MessageContext::Offers(OffersContext::InboundPayment { payment_hash, nonce, hmac });
+                                               Some((OffersMessage::Invoice(invoice), responder.respond_with_reply_path(context)))
+                                       },
                                        Err(error) => Some((OffersMessage::InvoiceError(error.into()), responder.respond())),
                                }
                        },