6 namespace org { namespace ldk { namespace structs {
10 * Builds an [`Offer`] for the \"offer to be paid\" flow.
12 * See [module-level documentation] for usage.
14 * [module-level documentation]: self
16 public class OfferWithDerivedMetadataBuilder : CommonBase {
17 internal OfferWithDerivedMetadataBuilder(object _dummy, long ptr) : base(ptr) { }
18 ~OfferWithDerivedMetadataBuilder() {
19 if (ptr != 0) { bindings.OfferWithDerivedMetadataBuilder_free(ptr); }
22 internal long clone_ptr() {
23 long ret = bindings.OfferWithDerivedMetadataBuilder_clone_ptr(this.ptr);
29 * Creates a copy of the OfferWithDerivedMetadataBuilder
31 public OfferWithDerivedMetadataBuilder clone() {
32 long ret = bindings.OfferWithDerivedMetadataBuilder_clone(this.ptr);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 org.ldk.structs.OfferWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithDerivedMetadataBuilder(null, ret); }
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
41 * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing
42 * pubkey is derived from the given [`ExpandedKey`] and [`EntropySource`]. This provides
43 * recipient privacy by using a different signing pubkey for each offer. Otherwise, the
44 * provided `node_id` is used for the signing pubkey.
46 * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by
47 * [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an
50 * [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify
51 * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
53 public static OfferWithDerivedMetadataBuilder deriving_signing_pubkey(byte[] node_id, org.ldk.structs.ExpandedKey expanded_key, org.ldk.structs.EntropySource entropy_source) {
54 long ret = bindings.OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id, 33)), expanded_key.ptr, entropy_source.ptr);
55 GC.KeepAlive(node_id);
56 GC.KeepAlive(expanded_key);
57 GC.KeepAlive(entropy_source);
58 if (ret >= 0 && ret <= 4096) { return null; }
59 org.ldk.structs.OfferWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithDerivedMetadataBuilder(null, ret); }
60 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
61 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(expanded_key); };
62 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
67 * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called,
68 * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported.
70 * See [`Offer::chains`] on how this relates to the payment currency.
72 * Successive calls to this method will add another chain hash.
74 public void chain(Network network) {
75 bindings.OfferWithDerivedMetadataBuilder_chain(this.ptr, network);
77 GC.KeepAlive(network);
78 if (this != null) { this.ptrs_to.AddLast(this); };
82 * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
84 * Successive calls to this method will override the previous setting.
86 public void amount_msats(long amount_msats) {
87 bindings.OfferWithDerivedMetadataBuilder_amount_msats(this.ptr, amount_msats);
89 GC.KeepAlive(amount_msats);
90 if (this != null) { this.ptrs_to.AddLast(this); };
94 * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
95 * already passed is valid and can be checked for using [`Offer::is_expired`].
97 * Successive calls to this method will override the previous setting.
99 public void absolute_expiry(long absolute_expiry) {
100 bindings.OfferWithDerivedMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
102 GC.KeepAlive(absolute_expiry);
103 if (this != null) { this.ptrs_to.AddLast(this); };
107 * Sets the [`Offer::description`].
109 * Successive calls to this method will override the previous setting.
111 public void description(string description) {
112 bindings.OfferWithDerivedMetadataBuilder_description(this.ptr, InternalUtils.encodeString(description));
114 GC.KeepAlive(description);
115 if (this != null) { this.ptrs_to.AddLast(this); };
119 * Sets the [`Offer::issuer`].
121 * Successive calls to this method will override the previous setting.
123 public void issuer(string issuer) {
124 bindings.OfferWithDerivedMetadataBuilder_issuer(this.ptr, InternalUtils.encodeString(issuer));
126 GC.KeepAlive(issuer);
127 if (this != null) { this.ptrs_to.AddLast(this); };
131 * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by
132 * private channels or if [`Offer::signing_pubkey`] is not a public node id.
134 * Successive calls to this method will add another blinded path. Caller is responsible for not
135 * adding duplicate paths.
137 public void path(org.ldk.structs.BlindedPath path) {
138 bindings.OfferWithDerivedMetadataBuilder_path(this.ptr, path.ptr);
141 if (this != null) { this.ptrs_to.AddLast(path); };
142 if (this != null) { this.ptrs_to.AddLast(this); };
146 * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
149 * Successive calls to this method will override the previous setting.
151 public void supported_quantity(org.ldk.structs.Quantity quantity) {
152 bindings.OfferWithDerivedMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
154 GC.KeepAlive(quantity);
155 if (this != null) { this.ptrs_to.AddLast(quantity); };
156 if (this != null) { this.ptrs_to.AddLast(this); };
160 * Builds an [`Offer`] from the builder's settings.
162 public Result_OfferBolt12SemanticErrorZ build() {
163 long ret = bindings.OfferWithDerivedMetadataBuilder_build(this.ptr);
165 if (ret >= 0 && ret <= 4096) { return null; }
166 Result_OfferBolt12SemanticErrorZ ret_hu_conv = Result_OfferBolt12SemanticErrorZ.constr_from_ptr(ret);
167 if (this != null) { this.ptrs_to.AddLast(this); };