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