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