[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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         public Option_AmountZ amount() {
79                 long ret = bindings.InvoiceRequest_amount(this.ptr);
80                 GC.KeepAlive(this);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
84                 return ret_hu_conv;
85         }
86
87         /**
88          * A complete description of the purpose of the payment. Intended to be displayed to the user
89          * but with the caveat that it has not been verified in any way.
90          * 
91          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 = org.ldk.structs.Quantity.constr_from_ptr(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          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
179          */
180         public byte[] signing_pubkey() {
181                 long ret = bindings.InvoiceRequest_signing_pubkey(this.ptr);
182                 GC.KeepAlive(this);
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
185                 return ret_conv;
186         }
187
188         /**
189          * An unpredictable series of bytes, typically containing information about the derivation of
190          * [`payer_id`].
191          * 
192          * [`payer_id`]: Self::payer_id
193          */
194         public byte[] payer_metadata() {
195                 long ret = bindings.InvoiceRequest_payer_metadata(this.ptr);
196                 GC.KeepAlive(this);
197                 if (ret >= 0 && ret <= 4096) { return null; }
198                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
199                 return ret_conv;
200         }
201
202         /**
203          * A chain from [`Offer::chains`] that the offer is valid for.
204          */
205         public byte[] chain() {
206                 long ret = bindings.InvoiceRequest_chain(this.ptr);
207                 GC.KeepAlive(this);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
210                 return ret_conv;
211         }
212
213         /**
214          * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
215          * must be greater than or equal to [`Offer::amount`], converted if necessary.
216          * 
217          * [`chain`]: Self::chain
218          */
219         public Option_u64Z amount_msats() {
220                 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
221                 GC.KeepAlive(this);
222                 if (ret >= 0 && ret <= 4096) { return null; }
223                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
224                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
225                 return ret_hu_conv;
226         }
227
228         /**
229          * Features pertaining to requesting an invoice.
230          */
231         public InvoiceRequestFeatures invoice_request_features() {
232                 long ret = bindings.InvoiceRequest_invoice_request_features(this.ptr);
233                 GC.KeepAlive(this);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
236                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
237                 return ret_hu_conv;
238         }
239
240         /**
241          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
242          */
243         public Option_u64Z quantity() {
244                 long ret = bindings.InvoiceRequest_quantity(this.ptr);
245                 GC.KeepAlive(this);
246                 if (ret >= 0 && ret <= 4096) { return null; }
247                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
248                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
249                 return ret_hu_conv;
250         }
251
252         /**
253          * A possibly transient pubkey used to sign the invoice request.
254          */
255         public byte[] payer_id() {
256                 long ret = bindings.InvoiceRequest_payer_id(this.ptr);
257                 GC.KeepAlive(this);
258                 if (ret >= 0 && ret <= 4096) { return null; }
259                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
260                 return ret_conv;
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         public PrintableString payer_note() {
270                 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
271                 GC.KeepAlive(this);
272                 if (ret >= 0 && ret <= 4096) { return null; }
273                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
274                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
275                 return ret_hu_conv;
276         }
277
278         /**
279          * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
280          * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
281          * 
282          * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
283          * creation time is used for the `created_at` parameter.
284          * 
285          * [`Duration`]: core::time::Duration
286          */
287         public Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ respond_with(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash) {
288                 long ret = bindings.InvoiceRequest_respond_with(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
289                 GC.KeepAlive(this);
290                 GC.KeepAlive(payment_paths);
291                 GC.KeepAlive(payment_hash);
292                 if (ret >= 0 && ret <= 4096) { return null; }
293                 Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
294                 return ret_hu_conv;
295         }
296
297         /**
298          * Creates an [`InvoiceBuilder`] for the request with the given required fields.
299          * 
300          * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
301          * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
302          * where [`std::time::SystemTime`] is not available.
303          * 
304          * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
305          * for the invoice.
306          * 
307          * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
308          * must contain one or more elements ordered from most-preferred to least-preferred, if there's
309          * a preference. Note, however, that any privacy is lost if a public node id was used for
310          * [`Offer::signing_pubkey`].
311          * 
312          * Errors if the request contains unknown required features.
313          * 
314          * # Note
315          * 
316          * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
317          * then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
318          * 
319          * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
320          * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
321          */
322         public Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ respond_with_no_std(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash, long created_at) {
323                 long ret = bindings.InvoiceRequest_respond_with_no_std(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), created_at);
324                 GC.KeepAlive(this);
325                 GC.KeepAlive(payment_paths);
326                 GC.KeepAlive(payment_hash);
327                 GC.KeepAlive(created_at);
328                 if (ret >= 0 && ret <= 4096) { return null; }
329                 Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
330                 return ret_hu_conv;
331         }
332
333         /**
334          * Verifies that the request was for an offer created using the given key. Returns the verified
335          * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
336          * if they could be extracted from the metadata.
337          * 
338          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
339          */
340         public Result_VerifiedInvoiceRequestNoneZ verify(org.ldk.structs.ExpandedKey key) {
341                 long ret = bindings.InvoiceRequest_verify(this.ptr, key.ptr);
342                 GC.KeepAlive(this);
343                 GC.KeepAlive(key);
344                 if (ret >= 0 && ret <= 4096) { return null; }
345                 Result_VerifiedInvoiceRequestNoneZ ret_hu_conv = Result_VerifiedInvoiceRequestNoneZ.constr_from_ptr(ret);
346                 if (this != null) { this.ptrs_to.AddLast(key); };
347                 if (this != null) { this.ptrs_to.AddLast(this); };
348                 return ret_hu_conv;
349         }
350
351         /**
352          * Signature of the invoice request using [`payer_id`].
353          * 
354          * [`payer_id`]: Self::payer_id
355          */
356         public byte[] signature() {
357                 long ret = bindings.InvoiceRequest_signature(this.ptr);
358                 GC.KeepAlive(this);
359                 if (ret >= 0 && ret <= 4096) { return null; }
360                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
361                 return ret_conv;
362         }
363
364         /**
365          * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
366          */
367         public byte[] write() {
368                 long ret = bindings.InvoiceRequest_write(this.ptr);
369                 GC.KeepAlive(this);
370                 if (ret >= 0 && ret <= 4096) { return null; }
371                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
372                 return ret_conv;
373         }
374
375 }
376 } } }