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