@@ -55,6 +55,10 @@ use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VA
55
55
use crate :: ln:: outbound_payment;
56
56
use crate :: ln:: outbound_payment:: { OutboundPayments , PaymentAttempts , PendingOutboundPayment } ;
57
57
use crate :: ln:: wire:: Encode ;
58
+ use crate :: offers:: invoice_request:: { DerivedPayerId , InvoiceRequestBuilder } ;
59
+ use crate :: offers:: offer:: { DerivedMetadata , Offer , OfferBuilder } ;
60
+ use crate :: offers:: parse:: SemanticError ;
61
+ use crate :: offers:: refund:: RefundBuilder ;
58
62
use crate :: sign:: { EntropySource , KeysManager , NodeSigner , Recipient , SignerProvider , ChannelSigner , WriteableEcdsaChannelSigner } ;
59
63
use crate :: util:: config:: { UserConfig , ChannelConfig } ;
60
64
use crate :: util:: wakers:: { Future , Notifier } ;
@@ -5734,6 +5738,60 @@ where
5734
5738
Ok ( payment_secret)
5735
5739
}
5736
5740
5741
+ /// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
5742
+ /// [`OnionMessenger`] when handling [`InvoiceRequest`] messages for the offer.
5743
+ ///
5744
+ /// [`Offer`]: crate::offers::offer::Offer
5745
+ /// [`OnionMessenger`]: crate::onion_message::OnionMessenger
5746
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
5747
+ pub fn create_offer_builder (
5748
+ & self , description : String
5749
+ ) -> OfferBuilder < DerivedMetadata , secp256k1:: All > {
5750
+ let node_id = self . get_our_node_id ( ) ;
5751
+ let expanded_key = & self . inbound_payment_key ;
5752
+ let entropy = & * self . entropy_source ;
5753
+ let secp_ctx = & self . secp_ctx ;
5754
+
5755
+ // TODO: Set blinded paths
5756
+ OfferBuilder :: deriving_signing_pubkey ( description, node_id, expanded_key, entropy, secp_ctx)
5757
+ }
5758
+
5759
+ /// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
5760
+ /// [`OnionMessenger`] when handling [`Invoice`] messages for the refund.
5761
+ ///
5762
+ /// [`Refund`]: crate::offers::refund::Refund
5763
+ /// [`OnionMessenger`]: crate::onion_message::OnionMessenger
5764
+ /// [`Invoice`]: crate::offers::invoice::Invoice
5765
+ pub fn create_refund_builder (
5766
+ & self , description : String , amount_msats : u64
5767
+ ) -> Result < RefundBuilder < secp256k1:: All > , SemanticError > {
5768
+ let node_id = self . get_our_node_id ( ) ;
5769
+ let expanded_key = & self . inbound_payment_key ;
5770
+ let entropy = & * self . entropy_source ;
5771
+ let secp_ctx = & self . secp_ctx ;
5772
+
5773
+ // TODO: Set blinded paths
5774
+ RefundBuilder :: deriving_payer_id (
5775
+ description, node_id, expanded_key, entropy, secp_ctx, amount_msats
5776
+ )
5777
+ }
5778
+
5779
+ /// Creates an [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is
5780
+ /// recognized by the [`OnionMessenger`] when handling [`Invoice`] messages for the request.
5781
+ ///
5782
+ /// [`OnionMessenger`]: crate::onion_message::OnionMessenger
5783
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
5784
+ /// [`Invoice`]: crate::offers::invoice::Invoice
5785
+ pub fn create_invoice_request_builder < ' a , ' b > (
5786
+ & ' b self , offer : & ' a Offer
5787
+ ) -> Result < InvoiceRequestBuilder < ' a , ' b , DerivedPayerId , secp256k1:: All > , SemanticError > {
5788
+ let expanded_key = & self . inbound_payment_key ;
5789
+ let entropy = & * self . entropy_source ;
5790
+ let secp_ctx = & self . secp_ctx ;
5791
+
5792
+ offer. request_invoice_deriving_payer_id ( expanded_key, entropy, secp_ctx)
5793
+ }
5794
+
5737
5795
/// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
5738
5796
/// to pay us.
5739
5797
///
0 commit comments