Skip to content

Commit

Permalink
f - create_invoice_request_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jkczyz committed Feb 19, 2023
1 parent d68484f commit 07a2742
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<InvoiceRequestBuilder<'a>, 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.
///
Expand Down

0 comments on commit 07a2742

Please sign in to comment.