[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / InvoiceRequest.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  * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
13  * 
14  * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
15  * specifies these such that its recipient can send an invoice for payment.
16  * 
17  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
18  * [`Offer`]: crate::offers::offer::Offer
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class InvoiceRequest extends CommonBase {
22         InvoiceRequest(Object _dummy, long ptr) { super(ptr); }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 super.finalize();
26                 if (ptr != 0) { bindings.InvoiceRequest_free(ptr); }
27         }
28
29         long clone_ptr() {
30                 long ret = bindings.InvoiceRequest_clone_ptr(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
36          * Creates a copy of the InvoiceRequest
37          */
38         public InvoiceRequest clone() {
39                 long ret = bindings.InvoiceRequest_clone(this.ptr);
40                 Reference.reachabilityFence(this);
41                 if (ret >= 0 && ret <= 4096) { return null; }
42                 org.ldk.structs.InvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequest(null, ret); }
43                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
44                 return ret_hu_conv;
45         }
46
47         /**
48          * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
49          * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
50          * for the selected chain.
51          */
52         public byte[][] chains() {
53                 byte[][] ret = bindings.InvoiceRequest_chains(this.ptr);
54                 Reference.reachabilityFence(this);
55                 return ret;
56         }
57
58         /**
59          * Opaque bytes set by the originator. Useful for authentication and validating fields since it
60          * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
61          */
62         public Option_CVec_u8ZZ metadata() {
63                 long ret = bindings.InvoiceRequest_metadata(this.ptr);
64                 Reference.reachabilityFence(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * The minimum amount required for a successful payment of a single item.
73          * 
74          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
75          */
76         @Nullable
77         public Amount amount() {
78                 long ret = bindings.InvoiceRequest_amount(this.ptr);
79                 Reference.reachabilityFence(this);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * A complete description of the purpose of the payment. Intended to be displayed to the user
88          * but with the caveat that it has not been verified in any way.
89          */
90         public PrintableString description() {
91                 long ret = bindings.InvoiceRequest_description(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Features pertaining to the offer.
101          */
102         public OfferFeatures offer_features() {
103                 long ret = bindings.InvoiceRequest_offer_features(this.ptr);
104                 Reference.reachabilityFence(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Duration since the Unix epoch when an invoice should no longer be requested.
113          * 
114          * If `None`, the offer does not expire.
115          */
116         public Option_u64Z absolute_expiry() {
117                 long ret = bindings.InvoiceRequest_absolute_expiry(this.ptr);
118                 Reference.reachabilityFence(this);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.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          * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
127          * displayed to the user but with the caveat that it has not been verified in any way.
128          * 
129          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
130          */
131         @Nullable
132         public PrintableString issuer() {
133                 long ret = bindings.InvoiceRequest_issuer(this.ptr);
134                 Reference.reachabilityFence(this);
135                 if (ret >= 0 && ret <= 4096) { return null; }
136                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
138                 return ret_hu_conv;
139         }
140
141         /**
142          * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
143          * recipient privacy by obfuscating its node id.
144          */
145         public BlindedPath[] paths() {
146                 long[] ret = bindings.InvoiceRequest_paths(this.ptr);
147                 Reference.reachabilityFence(this);
148                 int ret_conv_13_len = ret.length;
149                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
150                 for (int n = 0; n < ret_conv_13_len; n++) {
151                         long ret_conv_13 = ret[n];
152                         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); }
153                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
154                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
155                 }
156                 return ret_conv_13_arr;
157         }
158
159         /**
160          * The quantity of items supported.
161          */
162         public Quantity supported_quantity() {
163                 long ret = bindings.InvoiceRequest_supported_quantity(this.ptr);
164                 Reference.reachabilityFence(this);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
168                 return ret_hu_conv;
169         }
170
171         /**
172          * The public key used by the recipient to sign invoices.
173          */
174         public byte[] signing_pubkey() {
175                 byte[] ret = bindings.InvoiceRequest_signing_pubkey(this.ptr);
176                 Reference.reachabilityFence(this);
177                 return ret;
178         }
179
180         /**
181          * An unpredictable series of bytes, typically containing information about the derivation of
182          * [`payer_id`].
183          * 
184          * [`payer_id`]: Self::payer_id
185          */
186         public byte[] payer_metadata() {
187                 byte[] ret = bindings.InvoiceRequest_payer_metadata(this.ptr);
188                 Reference.reachabilityFence(this);
189                 return ret;
190         }
191
192         /**
193          * A chain from [`Offer::chains`] that the offer is valid for.
194          */
195         public byte[] chain() {
196                 byte[] ret = bindings.InvoiceRequest_chain(this.ptr);
197                 Reference.reachabilityFence(this);
198                 return ret;
199         }
200
201         /**
202          * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
203          * must be greater than or equal to [`Offer::amount`], converted if necessary.
204          * 
205          * [`chain`]: Self::chain
206          */
207         public Option_u64Z amount_msats() {
208                 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
209                 Reference.reachabilityFence(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Features pertaining to requesting an invoice.
218          */
219         public InvoiceRequestFeatures invoice_request_features() {
220                 long ret = bindings.InvoiceRequest_invoice_request_features(this.ptr);
221                 Reference.reachabilityFence(this);
222                 if (ret >= 0 && ret <= 4096) { return null; }
223                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
224                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
225                 return ret_hu_conv;
226         }
227
228         /**
229          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
230          */
231         public Option_u64Z quantity() {
232                 long ret = bindings.InvoiceRequest_quantity(this.ptr);
233                 Reference.reachabilityFence(this);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
236                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
237                 return ret_hu_conv;
238         }
239
240         /**
241          * A possibly transient pubkey used to sign the invoice request.
242          */
243         public byte[] payer_id() {
244                 byte[] ret = bindings.InvoiceRequest_payer_id(this.ptr);
245                 Reference.reachabilityFence(this);
246                 return ret;
247         }
248
249         /**
250          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
251          * response.
252          * 
253          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
254          */
255         @Nullable
256         public PrintableString payer_note() {
257                 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
258                 Reference.reachabilityFence(this);
259                 if (ret >= 0 && ret <= 4096) { return null; }
260                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
261                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
262                 return ret_hu_conv;
263         }
264
265         /**
266          * Signature of the invoice request using [`payer_id`].
267          * 
268          * [`payer_id`]: Self::payer_id
269          */
270         public byte[] signature() {
271                 byte[] ret = bindings.InvoiceRequest_signature(this.ptr);
272                 Reference.reachabilityFence(this);
273                 return ret;
274         }
275
276         /**
277          * Verifies that the request was for an offer created using the given key. Returns the verified
278          * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
279          * if they could be extracted from the metadata.
280          * 
281          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
282          */
283         public Result_VerifiedInvoiceRequestNoneZ verify(org.ldk.structs.ExpandedKey key) {
284                 long ret = bindings.InvoiceRequest_verify(this.ptr, key == null ? 0 : key.ptr);
285                 Reference.reachabilityFence(this);
286                 Reference.reachabilityFence(key);
287                 if (ret >= 0 && ret <= 4096) { return null; }
288                 Result_VerifiedInvoiceRequestNoneZ ret_hu_conv = Result_VerifiedInvoiceRequestNoneZ.constr_from_ptr(ret);
289                 if (this != null) { this.ptrs_to.add(key); };
290                 if (this != null) { this.ptrs_to.add(this); };
291                 return ret_hu_conv;
292         }
293
294         /**
295          * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
296          */
297         public byte[] write() {
298                 byte[] ret = bindings.InvoiceRequest_write(this.ptr);
299                 Reference.reachabilityFence(this);
300                 return ret;
301         }
302
303 }