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