@@ -57,8 +57,11 @@ use crate::ln::outbound_payment::{OutboundPayments, PaymentAttempts, PendingOutb
5757use crate::ln::wire::Encode;
5858use crate::offers::invoice::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, InvoiceBuilder};
5959use crate::offers::invoice_error::InvoiceError;
60+ use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequestBuilder};
6061use crate::offers::merkle::{SignError, TaggedHash};
62+ use crate::offers::offer::{DerivedMetadata, Offer, OfferBuilder};
6163use crate::offers::parse::Bolt12SemanticError;
64+ use crate::offers::refund::RefundBuilder;
6265use crate::onion_message::{OffersMessage, OffersMessageHandler};
6366use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider, ChannelSigner, WriteableEcdsaChannelSigner};
6467use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
@@ -6347,6 +6350,74 @@ where
63476350		}
63486351	}
63496352
6353+ 	/// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
6354+ 	/// [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer.
6355+ 	///
6356+ 	/// [`Offer`]: crate::offers::offer::Offer
6357+ 	/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
6358+ 	pub fn create_offer_builder(
6359+ 		&self, description: String
6360+ 	) -> OfferBuilder<DerivedMetadata, secp256k1::All> {
6361+ 		let node_id = self.get_our_node_id();
6362+ 		let expanded_key = &self.inbound_payment_key;
6363+ 		let entropy = &*self.entropy_source;
6364+ 		let secp_ctx = &self.secp_ctx;
6365+ 
6366+ 		// TODO: Set blinded paths
6367+ 		OfferBuilder::deriving_signing_pubkey(description, node_id, expanded_key, entropy, secp_ctx)
6368+ 	}
6369+ 
6370+ 	/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
6371+ 	/// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund.
6372+ 	///
6373+ 	/// The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
6374+ 	///
6375+ 	/// [`Refund`]: crate::offers::refund::Refund
6376+ 	/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
6377+ 	pub fn create_refund_builder(
6378+ 		&self, description: String, amount_msats: u64, payment_id: PaymentId
6379+ 	) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError> {
6380+ 		let node_id = self.get_our_node_id();
6381+ 		let expanded_key = &self.inbound_payment_key;
6382+ 		let entropy = &*self.entropy_source;
6383+ 		let secp_ctx = &self.secp_ctx;
6384+ 
6385+ 		// TODO: Set blinded paths
6386+ 		let builder = RefundBuilder::deriving_payer_id(
6387+ 			description, node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
6388+ 		)?;
6389+ 		self.pending_outbound_payments
6390+ 			.add_new_awaiting_invoice(payment_id)
6391+ 			.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
6392+ 
6393+ 		Ok(builder)
6394+ 	}
6395+ 
6396+ 	/// Creates an [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is
6397+ 	/// recognized by the [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the
6398+ 	/// request.
6399+ 	///
6400+ 	/// The provided `payment_id` is used to ensure that only one invoice is paid for the request.
6401+ 	///
6402+ 	/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
6403+ 	/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
6404+ 	pub fn create_invoice_request_builder<'a, 'b>(
6405+ 		&'b self, offer: &'a Offer, payment_id: PaymentId
6406+ 	) -> Result<InvoiceRequestBuilder<'a, 'b, DerivedPayerId, secp256k1::All>, Bolt12SemanticError> {
6407+ 		let expanded_key = &self.inbound_payment_key;
6408+ 		let entropy = &*self.entropy_source;
6409+ 		let secp_ctx = &self.secp_ctx;
6410+ 
6411+ 		let builder = offer.request_invoice_deriving_payer_id(
6412+ 			expanded_key, entropy, secp_ctx, payment_id
6413+ 		)?;
6414+ 		self.pending_outbound_payments
6415+ 			.add_new_awaiting_invoice(payment_id)
6416+ 			.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
6417+ 
6418+ 		Ok(builder)
6419+ 	}
6420+ 
63506421	/// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
63516422	/// to pay us.
63526423	///
0 commit comments