[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / OfferWithExplicitMetadataBuilder.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Builds an [`Offer`] for the \"offer to be paid\" flow.
13  * 
14  * See [module-level documentation] for usage.
15  * 
16  * [module-level documentation]: self
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class OfferWithExplicitMetadataBuilder extends CommonBase {
20         OfferWithExplicitMetadataBuilder(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.OfferWithExplicitMetadataBuilder_free(ptr); }
25         }
26
27         long clone_ptr() {
28                 long ret = bindings.OfferWithExplicitMetadataBuilder_clone_ptr(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * Creates a copy of the OfferWithExplicitMetadataBuilder
35          */
36         public OfferWithExplicitMetadataBuilder clone() {
37                 long ret = bindings.OfferWithExplicitMetadataBuilder_clone(this.ptr);
38                 Reference.reachabilityFence(this);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 org.ldk.structs.OfferWithExplicitMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithExplicitMetadataBuilder(null, ret); }
41                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
42                 return ret_hu_conv;
43         }
44
45         /**
46          * Creates a new builder for an offer using the [`Offer::signing_pubkey`] for signing invoices.
47          * The associated secret key must be remembered while the offer is valid.
48          * 
49          * Use a different pubkey per offer to avoid correlating offers.
50          * 
51          * # Note
52          * 
53          * If constructing an [`Offer`] for use with a [`ChannelManager`], use
54          * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`].
55          * 
56          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
57          * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder
58          */
59         public static OfferWithExplicitMetadataBuilder of(byte[] signing_pubkey) {
60                 long ret = bindings.OfferWithExplicitMetadataBuilder_new(InternalUtils.check_arr_len(signing_pubkey, 33));
61                 Reference.reachabilityFence(signing_pubkey);
62                 if (ret >= 0 && ret <= 4096) { return null; }
63                 org.ldk.structs.OfferWithExplicitMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithExplicitMetadataBuilder(null, ret); }
64                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
65                 return ret_hu_conv;
66         }
67
68         /**
69          * Sets the [`Offer::metadata`] to the given bytes.
70          * 
71          * Successive calls to this method will override the previous setting.
72          */
73         public Result_NoneBolt12SemanticErrorZ metadata(byte[] metadata) {
74                 long ret = bindings.OfferWithExplicitMetadataBuilder_metadata(this.ptr, metadata);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(metadata);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
79                 if (this != null) { this.ptrs_to.add(this); };
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called,
85          * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported.
86          * 
87          * See [`Offer::chains`] on how this relates to the payment currency.
88          * 
89          * Successive calls to this method will add another chain hash.
90          */
91         public void chain(org.ldk.enums.Network network) {
92                 bindings.OfferWithExplicitMetadataBuilder_chain(this.ptr, network);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(network);
95                 if (this != null) { this.ptrs_to.add(this); };
96         }
97
98         /**
99          * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
100          * 
101          * Successive calls to this method will override the previous setting.
102          */
103         public void amount_msats(long amount_msats) {
104                 bindings.OfferWithExplicitMetadataBuilder_amount_msats(this.ptr, amount_msats);
105                 Reference.reachabilityFence(this);
106                 Reference.reachabilityFence(amount_msats);
107                 if (this != null) { this.ptrs_to.add(this); };
108         }
109
110         /**
111          * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
112          * already passed is valid and can be checked for using [`Offer::is_expired`].
113          * 
114          * Successive calls to this method will override the previous setting.
115          */
116         public void absolute_expiry(long absolute_expiry) {
117                 bindings.OfferWithExplicitMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
118                 Reference.reachabilityFence(this);
119                 Reference.reachabilityFence(absolute_expiry);
120                 if (this != null) { this.ptrs_to.add(this); };
121         }
122
123         /**
124          * Sets the [`Offer::description`].
125          * 
126          * Successive calls to this method will override the previous setting.
127          */
128         public void description(java.lang.String description) {
129                 bindings.OfferWithExplicitMetadataBuilder_description(this.ptr, description);
130                 Reference.reachabilityFence(this);
131                 Reference.reachabilityFence(description);
132                 if (this != null) { this.ptrs_to.add(this); };
133         }
134
135         /**
136          * Sets the [`Offer::issuer`].
137          * 
138          * Successive calls to this method will override the previous setting.
139          */
140         public void issuer(java.lang.String issuer) {
141                 bindings.OfferWithExplicitMetadataBuilder_issuer(this.ptr, issuer);
142                 Reference.reachabilityFence(this);
143                 Reference.reachabilityFence(issuer);
144                 if (this != null) { this.ptrs_to.add(this); };
145         }
146
147         /**
148          * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by
149          * private channels or if [`Offer::signing_pubkey`] is not a public node id.
150          * 
151          * Successive calls to this method will add another blinded path. Caller is responsible for not
152          * adding duplicate paths.
153          */
154         public void path(org.ldk.structs.BlindedPath path) {
155                 bindings.OfferWithExplicitMetadataBuilder_path(this.ptr, path.ptr);
156                 Reference.reachabilityFence(this);
157                 Reference.reachabilityFence(path);
158                 if (this != null) { this.ptrs_to.add(path); };
159                 if (this != null) { this.ptrs_to.add(this); };
160         }
161
162         /**
163          * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
164          * [`Quantity::One`].
165          * 
166          * Successive calls to this method will override the previous setting.
167          */
168         public void supported_quantity(org.ldk.structs.Quantity quantity) {
169                 bindings.OfferWithExplicitMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
170                 Reference.reachabilityFence(this);
171                 Reference.reachabilityFence(quantity);
172                 if (this != null) { this.ptrs_to.add(quantity); };
173                 if (this != null) { this.ptrs_to.add(this); };
174         }
175
176         /**
177          * Builds an [`Offer`] from the builder's settings.
178          */
179         public Result_OfferBolt12SemanticErrorZ build() {
180                 long ret = bindings.OfferWithExplicitMetadataBuilder_build(this.ptr);
181                 Reference.reachabilityFence(this);
182                 if (ret >= 0 && ret <= 4096) { return null; }
183                 Result_OfferBolt12SemanticErrorZ ret_hu_conv = Result_OfferBolt12SemanticErrorZ.constr_from_ptr(ret);
184                 if (this != null) { this.ptrs_to.add(this); };
185                 return ret_hu_conv;
186         }
187
188 }