diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index bedabc8b4f4..19d93ba7b86 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -56,7 +56,8 @@ use crate::ln::outbound_payment; use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutboundPayment, Retry}; use crate::ln::wire::Encode; use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider, ChannelSigner}; -use crate::offers::offer::OfferBuilder; +use crate::offers::invoice_request::InvoiceRequestBuilder; +use crate::offers::offer::{Offer, OfferBuilder}; use crate::offers::parse::SemanticError; use crate::offers::refund::RefundBuilder; use crate::offers::signer::DerivedPubkey; @@ -5352,6 +5353,21 @@ where RefundBuilder::deriving_payer_id(description, payer_id, amount_msats) } + /// Creates an [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is + /// recognized by the [`OnionMessenger`] when handling [`Invoice`] messages for the request. + /// + /// [`OnionMessenger`]: crate::onion_message::OnionMessenger + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + /// [`Invoice`]: crate::offers::invoice::Invoice + pub fn create_invoice_request_builder<'a>( + &self, offer: &'a Offer + ) -> Result, SemanticError> { + let nonce = inbound_payment::Nonce::from_entropy_source(&*self.entropy_source); + let payer_id = DerivedPubkey::new(&self.inbound_payment_key, nonce); + + offer.request_invoice_deriving_payer_id(payer_id) + } + /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing /// to pay us. ///