8034c1543b0b1cfdb6e6126997909970f922c921
[ldk-java] / src / main / java / org / ldk / structs / UnsignedInvoiceRequest.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 [`InvoiceRequest`] 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 UnsignedInvoiceRequest extends CommonBase {
21         UnsignedInvoiceRequest(Object _dummy, long ptr) { super(ptr); }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 super.finalize();
25                 if (ptr != 0) { bindings.UnsignedInvoiceRequest_free(ptr); }
26         }
27
28         long clone_ptr() {
29                 long ret = bindings.UnsignedInvoiceRequest_clone_ptr(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * Creates a copy of the UnsignedInvoiceRequest
36          */
37         public UnsignedInvoiceRequest clone() {
38                 long ret = bindings.UnsignedInvoiceRequest_clone(this.ptr);
39                 Reference.reachabilityFence(this);
40                 if (ret >= 0 && ret <= 4096) { return null; }
41                 org.ldk.structs.UnsignedInvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedInvoiceRequest(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.UnsignedInvoiceRequest_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 (e.g., bitcoin mainnet).
60          * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
61          * for the selected chain.
62          */
63         public byte[][] chains() {
64                 byte[][] ret = bindings.UnsignedInvoiceRequest_chains(this.ptr);
65                 Reference.reachabilityFence(this);
66                 return ret;
67         }
68
69         /**
70          * Opaque bytes set by the originator. Useful for authentication and validating fields since it
71          * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
72          */
73         public Option_CVec_u8ZZ metadata() {
74                 long ret = bindings.UnsignedInvoiceRequest_metadata(this.ptr);
75                 Reference.reachabilityFence(this);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
79                 return ret_hu_conv;
80         }
81
82         /**
83          * The minimum amount required for a successful payment of a single item.
84          */
85         public Option_AmountZ amount() {
86                 long ret = bindings.UnsignedInvoiceRequest_amount(this.ptr);
87                 Reference.reachabilityFence(this);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * A complete description of the purpose of the payment. Intended to be displayed to the user
96          * but with the caveat that it has not been verified in any way.
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 PrintableString description() {
102                 long ret = bindings.UnsignedInvoiceRequest_description(this.ptr);
103                 Reference.reachabilityFence(this);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(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 offer.
112          */
113         public OfferFeatures offer_features() {
114                 long ret = bindings.UnsignedInvoiceRequest_offer_features(this.ptr);
115                 Reference.reachabilityFence(this);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Duration since the Unix epoch when an invoice should no longer be requested.
124          * 
125          * If `None`, the offer does not expire.
126          */
127         public Option_u64Z absolute_expiry() {
128                 long ret = bindings.UnsignedInvoiceRequest_absolute_expiry(this.ptr);
129                 Reference.reachabilityFence(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133                 return ret_hu_conv;
134         }
135
136         /**
137          * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
138          * displayed to the user but with the caveat that it has not been verified in any way.
139          * 
140          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
141          */
142         @Nullable
143         public PrintableString issuer() {
144                 long ret = bindings.UnsignedInvoiceRequest_issuer(this.ptr);
145                 Reference.reachabilityFence(this);
146                 if (ret >= 0 && ret <= 4096) { return null; }
147                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
148                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
149                 return ret_hu_conv;
150         }
151
152         /**
153          * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
154          * recipient privacy by obfuscating its node id.
155          */
156         public BlindedPath[] paths() {
157                 long[] ret = bindings.UnsignedInvoiceRequest_paths(this.ptr);
158                 Reference.reachabilityFence(this);
159                 int ret_conv_13_len = ret.length;
160                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
161                 for (int n = 0; n < ret_conv_13_len; n++) {
162                         long ret_conv_13 = ret[n];
163                         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); }
164                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
165                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
166                 }
167                 return ret_conv_13_arr;
168         }
169
170         /**
171          * The quantity of items supported.
172          */
173         public Quantity supported_quantity() {
174                 long ret = bindings.UnsignedInvoiceRequest_supported_quantity(this.ptr);
175                 Reference.reachabilityFence(this);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
178                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
179                 return ret_hu_conv;
180         }
181
182         /**
183          * The public key used by the recipient to sign invoices.
184          * 
185          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
186          */
187         @Nullable
188         public byte[] signing_pubkey() {
189                 byte[] ret = bindings.UnsignedInvoiceRequest_signing_pubkey(this.ptr);
190                 Reference.reachabilityFence(this);
191                 return ret;
192         }
193
194         /**
195          * An unpredictable series of bytes, typically containing information about the derivation of
196          * [`payer_id`].
197          * 
198          * [`payer_id`]: Self::payer_id
199          */
200         public byte[] payer_metadata() {
201                 byte[] ret = bindings.UnsignedInvoiceRequest_payer_metadata(this.ptr);
202                 Reference.reachabilityFence(this);
203                 return ret;
204         }
205
206         /**
207          * A chain from [`Offer::chains`] that the offer is valid for.
208          */
209         public byte[] chain() {
210                 byte[] ret = bindings.UnsignedInvoiceRequest_chain(this.ptr);
211                 Reference.reachabilityFence(this);
212                 return ret;
213         }
214
215         /**
216          * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
217          * must be greater than or equal to [`Offer::amount`], converted if necessary.
218          * 
219          * [`chain`]: Self::chain
220          */
221         public Option_u64Z amount_msats() {
222                 long ret = bindings.UnsignedInvoiceRequest_amount_msats(this.ptr);
223                 Reference.reachabilityFence(this);
224                 if (ret >= 0 && ret <= 4096) { return null; }
225                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
226                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
227                 return ret_hu_conv;
228         }
229
230         /**
231          * Features pertaining to requesting an invoice.
232          */
233         public InvoiceRequestFeatures invoice_request_features() {
234                 long ret = bindings.UnsignedInvoiceRequest_invoice_request_features(this.ptr);
235                 Reference.reachabilityFence(this);
236                 if (ret >= 0 && ret <= 4096) { return null; }
237                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
238                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
239                 return ret_hu_conv;
240         }
241
242         /**
243          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
244          */
245         public Option_u64Z quantity() {
246                 long ret = bindings.UnsignedInvoiceRequest_quantity(this.ptr);
247                 Reference.reachabilityFence(this);
248                 if (ret >= 0 && ret <= 4096) { return null; }
249                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
250                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
251                 return ret_hu_conv;
252         }
253
254         /**
255          * A possibly transient pubkey used to sign the invoice request.
256          */
257         public byte[] payer_id() {
258                 byte[] ret = bindings.UnsignedInvoiceRequest_payer_id(this.ptr);
259                 Reference.reachabilityFence(this);
260                 return ret;
261         }
262
263         /**
264          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
265          * response.
266          * 
267          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
268          */
269         @Nullable
270         public PrintableString payer_note() {
271                 long ret = bindings.UnsignedInvoiceRequest_payer_note(this.ptr);
272                 Reference.reachabilityFence(this);
273                 if (ret >= 0 && ret <= 4096) { return null; }
274                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
275                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
276                 return ret_hu_conv;
277         }
278
279         /**
280          * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
281          */
282         public byte[] write() {
283                 byte[] ret = bindings.UnsignedInvoiceRequest_write(this.ptr);
284                 Reference.reachabilityFence(this);
285                 return ret;
286         }
287
288 }