[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / main / java / org / ldk / structs / UnsignedBolt12Invoice.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  * A semantically valid [`Bolt12Invoice`] that hasn't been signed.
13  * 
14  * # Serialization
15  * 
16  * This is serialized as a TLV stream, which includes TLV records from the originating message. As
17  * such, it may include unknown, odd TLV records.
18  */
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class UnsignedBolt12Invoice extends CommonBase {
21         UnsignedBolt12Invoice(Object _dummy, long ptr) { super(ptr); }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 super.finalize();
25                 if (ptr != 0) { bindings.UnsignedBolt12Invoice_free(ptr); }
26         }
27
28         long clone_ptr() {
29                 long ret = bindings.UnsignedBolt12Invoice_clone_ptr(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * Creates a copy of the UnsignedBolt12Invoice
36          */
37         public UnsignedBolt12Invoice clone() {
38                 long ret = bindings.UnsignedBolt12Invoice_clone(this.ptr);
39                 Reference.reachabilityFence(this);
40                 if (ret >= 0 && ret <= 4096) { return null; }
41                 org.ldk.structs.UnsignedBolt12Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedBolt12Invoice(null, ret); }
42                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
43                 return ret_hu_conv;
44         }
45
46         /**
47          * Returns the [`TaggedHash`] of the invoice to sign.
48          */
49         public TaggedHash tagged_hash() {
50                 long ret = bindings.UnsignedBolt12Invoice_tagged_hash(this.ptr);
51                 Reference.reachabilityFence(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 org.ldk.structs.TaggedHash ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TaggedHash(null, ret); }
54                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * The chains that may be used when paying a requested invoice.
60          * 
61          * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
62          * 
63          * [`Offer::chains`]: crate::offers::offer::Offer::chains
64          */
65         public Option_CVec_ThirtyTwoBytesZZ offer_chains() {
66                 long ret = bindings.UnsignedBolt12Invoice_offer_chains(this.ptr);
67                 Reference.reachabilityFence(this);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
71                 return ret_hu_conv;
72         }
73
74         /**
75          * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
76          * invoice originated from an offer.
77          * 
78          * From [`InvoiceRequest::chain`] or [`Refund::chain`].
79          * 
80          * [`offer_chains`]: Self::offer_chains
81          * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
82          */
83         public byte[] chain() {
84                 byte[] ret = bindings.UnsignedBolt12Invoice_chain(this.ptr);
85                 Reference.reachabilityFence(this);
86                 return ret;
87         }
88
89         /**
90          * Opaque bytes set by the originating [`Offer`].
91          * 
92          * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
93          * if the [`Offer`] did not set it.
94          * 
95          * [`Offer`]: crate::offers::offer::Offer
96          * [`Offer::metadata`]: crate::offers::offer::Offer::metadata
97          */
98         public Option_CVec_u8ZZ metadata() {
99                 long ret = bindings.UnsignedBolt12Invoice_metadata(this.ptr);
100                 Reference.reachabilityFence(this);
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
104                 return ret_hu_conv;
105         }
106
107         /**
108          * The minimum amount required for a successful payment of a single item.
109          * 
110          * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
111          * the [`Offer`] did not set it.
112          * 
113          * [`Offer`]: crate::offers::offer::Offer
114          * [`Offer::amount`]: crate::offers::offer::Offer::amount
115          */
116         public Option_AmountZ amount() {
117                 long ret = bindings.UnsignedBolt12Invoice_amount(this.ptr);
118                 Reference.reachabilityFence(this);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Features pertaining to the originating [`Offer`].
127          * 
128          * From [`Offer::offer_features`]; `None` if the invoice was created in response to a
129          * [`Refund`].
130          * 
131          * [`Offer`]: crate::offers::offer::Offer
132          * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
133          * 
134          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
135          */
136         @Nullable
137         public OfferFeatures offer_features() {
138                 long ret = bindings.UnsignedBolt12Invoice_offer_features(this.ptr);
139                 Reference.reachabilityFence(this);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
143                 return ret_hu_conv;
144         }
145
146         /**
147          * A complete description of the purpose of the originating offer or refund.
148          * 
149          * From [`Offer::description`] or [`Refund::description`].
150          * 
151          * [`Offer::description`]: crate::offers::offer::Offer::description
152          * 
153          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
154          */
155         @Nullable
156         public PrintableString description() {
157                 long ret = bindings.UnsignedBolt12Invoice_description(this.ptr);
158                 Reference.reachabilityFence(this);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
161                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
162                 return ret_hu_conv;
163         }
164
165         /**
166          * Duration since the Unix epoch when an invoice should no longer be requested.
167          * 
168          * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
169          * 
170          * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
171          */
172         public Option_u64Z absolute_expiry() {
173                 long ret = bindings.UnsignedBolt12Invoice_absolute_expiry(this.ptr);
174                 Reference.reachabilityFence(this);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
177                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
178                 return ret_hu_conv;
179         }
180
181         /**
182          * The issuer of the offer or refund.
183          * 
184          * From [`Offer::issuer`] or [`Refund::issuer`].
185          * 
186          * [`Offer::issuer`]: crate::offers::offer::Offer::issuer
187          * 
188          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
189          */
190         @Nullable
191         public PrintableString issuer() {
192                 long ret = bindings.UnsignedBolt12Invoice_issuer(this.ptr);
193                 Reference.reachabilityFence(this);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
196                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
197                 return ret_hu_conv;
198         }
199
200         /**
201          * Paths to the recipient originating from publicly reachable nodes.
202          * 
203          * From [`Offer::paths`] or [`Refund::paths`].
204          * 
205          * [`Offer::paths`]: crate::offers::offer::Offer::paths
206          */
207         public BlindedPath[] message_paths() {
208                 long[] ret = bindings.UnsignedBolt12Invoice_message_paths(this.ptr);
209                 Reference.reachabilityFence(this);
210                 int ret_conv_13_len = ret.length;
211                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
212                 for (int n = 0; n < ret_conv_13_len; n++) {
213                         long ret_conv_13 = ret[n];
214                         org.ldk.structs.BlindedPath ret_conv_13_hu_conv = null; if (ret_conv_13 < 0 || ret_conv_13 > 4096) { ret_conv_13_hu_conv = new org.ldk.structs.BlindedPath(null, ret_conv_13); }
215                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
216                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
217                 }
218                 return ret_conv_13_arr;
219         }
220
221         /**
222          * The quantity of items supported.
223          * 
224          * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
225          * [`Refund`].
226          * 
227          * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
228          */
229         public Option_QuantityZ supported_quantity() {
230                 long ret = bindings.UnsignedBolt12Invoice_supported_quantity(this.ptr);
231                 Reference.reachabilityFence(this);
232                 if (ret >= 0 && ret <= 4096) { return null; }
233                 org.ldk.structs.Option_QuantityZ ret_hu_conv = org.ldk.structs.Option_QuantityZ.constr_from_ptr(ret);
234                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
235                 return ret_hu_conv;
236         }
237
238         /**
239          * An unpredictable series of bytes from the payer.
240          * 
241          * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
242          */
243         public byte[] payer_metadata() {
244                 byte[] ret = bindings.UnsignedBolt12Invoice_payer_metadata(this.ptr);
245                 Reference.reachabilityFence(this);
246                 return ret;
247         }
248
249         /**
250          * Features pertaining to requesting an invoice.
251          * 
252          * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
253          */
254         public InvoiceRequestFeatures invoice_request_features() {
255                 long ret = bindings.UnsignedBolt12Invoice_invoice_request_features(this.ptr);
256                 Reference.reachabilityFence(this);
257                 if (ret >= 0 && ret <= 4096) { return null; }
258                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
259                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
260                 return ret_hu_conv;
261         }
262
263         /**
264          * The quantity of items requested or refunded for.
265          * 
266          * From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
267          */
268         public Option_u64Z quantity() {
269                 long ret = bindings.UnsignedBolt12Invoice_quantity(this.ptr);
270                 Reference.reachabilityFence(this);
271                 if (ret >= 0 && ret <= 4096) { return null; }
272                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
273                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
274                 return ret_hu_conv;
275         }
276
277         /**
278          * A possibly transient pubkey used to sign the invoice request or to send an invoice for a
279          * refund in case there are no [`message_paths`].
280          * 
281          * [`message_paths`]: Self::message_paths
282          */
283         public byte[] payer_id() {
284                 byte[] ret = bindings.UnsignedBolt12Invoice_payer_id(this.ptr);
285                 Reference.reachabilityFence(this);
286                 return ret;
287         }
288
289         /**
290          * A payer-provided note reflected back in the invoice.
291          * 
292          * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
293          * 
294          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
295          */
296         @Nullable
297         public PrintableString payer_note() {
298                 long ret = bindings.UnsignedBolt12Invoice_payer_note(this.ptr);
299                 Reference.reachabilityFence(this);
300                 if (ret >= 0 && ret <= 4096) { return null; }
301                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
302                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
303                 return ret_hu_conv;
304         }
305
306         /**
307          * Duration since the Unix epoch when the invoice was created.
308          */
309         public long created_at() {
310                 long ret = bindings.UnsignedBolt12Invoice_created_at(this.ptr);
311                 Reference.reachabilityFence(this);
312                 return ret;
313         }
314
315         /**
316          * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
317          * should no longer be paid.
318          */
319         public long relative_expiry() {
320                 long ret = bindings.UnsignedBolt12Invoice_relative_expiry(this.ptr);
321                 Reference.reachabilityFence(this);
322                 return ret;
323         }
324
325         /**
326          * Whether the invoice has expired.
327          */
328         public boolean is_expired() {
329                 boolean ret = bindings.UnsignedBolt12Invoice_is_expired(this.ptr);
330                 Reference.reachabilityFence(this);
331                 return ret;
332         }
333
334         /**
335          * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
336          */
337         public byte[] payment_hash() {
338                 byte[] ret = bindings.UnsignedBolt12Invoice_payment_hash(this.ptr);
339                 Reference.reachabilityFence(this);
340                 return ret;
341         }
342
343         /**
344          * The minimum amount required for a successful payment of the invoice.
345          */
346         public long amount_msats() {
347                 long ret = bindings.UnsignedBolt12Invoice_amount_msats(this.ptr);
348                 Reference.reachabilityFence(this);
349                 return ret;
350         }
351
352         /**
353          * Features pertaining to paying an invoice.
354          */
355         public Bolt12InvoiceFeatures invoice_features() {
356                 long ret = bindings.UnsignedBolt12Invoice_invoice_features(this.ptr);
357                 Reference.reachabilityFence(this);
358                 if (ret >= 0 && ret <= 4096) { return null; }
359                 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
360                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
361                 return ret_hu_conv;
362         }
363
364         /**
365          * The public key corresponding to the key used to sign the invoice.
366          */
367         public byte[] signing_pubkey() {
368                 byte[] ret = bindings.UnsignedBolt12Invoice_signing_pubkey(this.ptr);
369                 Reference.reachabilityFence(this);
370                 return ret;
371         }
372
373         /**
374          * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
375          */
376         public byte[] write() {
377                 byte[] ret = bindings.UnsignedBolt12Invoice_write(this.ptr);
378                 Reference.reachabilityFence(this);
379                 return ret;
380         }
381
382 }