[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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         public Option_AmountZ amount() {
104                 long ret = bindings.Bolt12Invoice_amount(this.ptr);
105                 GC.KeepAlive(this);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109                 return ret_hu_conv;
110         }
111
112         /**
113          * Features pertaining to the originating [`Offer`].
114          * 
115          * From [`Offer::offer_features`]; `None` if the invoice was created in response to a
116          * [`Refund`].
117          * 
118          * [`Offer`]: crate::offers::offer::Offer
119          * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
120          * 
121          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
122          */
123         public OfferFeatures offer_features() {
124                 long ret = bindings.Bolt12Invoice_offer_features(this.ptr);
125                 GC.KeepAlive(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * A complete description of the purpose of the originating offer or refund.
134          * 
135          * From [`Offer::description`] or [`Refund::description`].
136          * 
137          * [`Offer::description`]: crate::offers::offer::Offer::description
138          * 
139          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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         public Option_QuantityZ supported_quantity() {
216                 long ret = bindings.Bolt12Invoice_supported_quantity(this.ptr);
217                 GC.KeepAlive(this);
218                 if (ret >= 0 && ret <= 4096) { return null; }
219                 org.ldk.structs.Option_QuantityZ ret_hu_conv = org.ldk.structs.Option_QuantityZ.constr_from_ptr(ret);
220                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
221                 return ret_hu_conv;
222         }
223
224         /**
225          * An unpredictable series of bytes from the payer.
226          * 
227          * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
228          */
229         public byte[] payer_metadata() {
230                 long ret = bindings.Bolt12Invoice_payer_metadata(this.ptr);
231                 GC.KeepAlive(this);
232                 if (ret >= 0 && ret <= 4096) { return null; }
233                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
234                 return ret_conv;
235         }
236
237         /**
238          * Features pertaining to requesting an invoice.
239          * 
240          * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
241          */
242         public InvoiceRequestFeatures invoice_request_features() {
243                 long ret = bindings.Bolt12Invoice_invoice_request_features(this.ptr);
244                 GC.KeepAlive(this);
245                 if (ret >= 0 && ret <= 4096) { return null; }
246                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
247                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
248                 return ret_hu_conv;
249         }
250
251         /**
252          * The quantity of items requested or refunded for.
253          * 
254          * From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
255          */
256         public Option_u64Z quantity() {
257                 long ret = bindings.Bolt12Invoice_quantity(this.ptr);
258                 GC.KeepAlive(this);
259                 if (ret >= 0 && ret <= 4096) { return null; }
260                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
261                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
262                 return ret_hu_conv;
263         }
264
265         /**
266          * A possibly transient pubkey used to sign the invoice request or to send an invoice for a
267          * refund in case there are no [`message_paths`].
268          * 
269          * [`message_paths`]: Self::message_paths
270          */
271         public byte[] payer_id() {
272                 long ret = bindings.Bolt12Invoice_payer_id(this.ptr);
273                 GC.KeepAlive(this);
274                 if (ret >= 0 && ret <= 4096) { return null; }
275                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
276                 return ret_conv;
277         }
278
279         /**
280          * A payer-provided note reflected back in the invoice.
281          * 
282          * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
283          * 
284          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
285          */
286         public PrintableString payer_note() {
287                 long ret = bindings.Bolt12Invoice_payer_note(this.ptr);
288                 GC.KeepAlive(this);
289                 if (ret >= 0 && ret <= 4096) { return null; }
290                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
291                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
292                 return ret_hu_conv;
293         }
294
295         /**
296          * Duration since the Unix epoch when the invoice was created.
297          */
298         public long created_at() {
299                 long ret = bindings.Bolt12Invoice_created_at(this.ptr);
300                 GC.KeepAlive(this);
301                 return ret;
302         }
303
304         /**
305          * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
306          * should no longer be paid.
307          */
308         public long relative_expiry() {
309                 long ret = bindings.Bolt12Invoice_relative_expiry(this.ptr);
310                 GC.KeepAlive(this);
311                 return ret;
312         }
313
314         /**
315          * Whether the invoice has expired.
316          */
317         public bool is_expired() {
318                 bool ret = bindings.Bolt12Invoice_is_expired(this.ptr);
319                 GC.KeepAlive(this);
320                 return ret;
321         }
322
323         /**
324          * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
325          */
326         public byte[] payment_hash() {
327                 long ret = bindings.Bolt12Invoice_payment_hash(this.ptr);
328                 GC.KeepAlive(this);
329                 if (ret >= 0 && ret <= 4096) { return null; }
330                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
331                 return ret_conv;
332         }
333
334         /**
335          * The minimum amount required for a successful payment of the invoice.
336          */
337         public long amount_msats() {
338                 long ret = bindings.Bolt12Invoice_amount_msats(this.ptr);
339                 GC.KeepAlive(this);
340                 return ret;
341         }
342
343         /**
344          * Features pertaining to paying an invoice.
345          */
346         public Bolt12InvoiceFeatures invoice_features() {
347                 long ret = bindings.Bolt12Invoice_invoice_features(this.ptr);
348                 GC.KeepAlive(this);
349                 if (ret >= 0 && ret <= 4096) { return null; }
350                 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
351                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
352                 return ret_hu_conv;
353         }
354
355         /**
356          * The public key corresponding to the key used to sign the invoice.
357          */
358         public byte[] signing_pubkey() {
359                 long ret = bindings.Bolt12Invoice_signing_pubkey(this.ptr);
360                 GC.KeepAlive(this);
361                 if (ret >= 0 && ret <= 4096) { return null; }
362                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
363                 return ret_conv;
364         }
365
366         /**
367          * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
368          */
369         public byte[] signature() {
370                 long ret = bindings.Bolt12Invoice_signature(this.ptr);
371                 GC.KeepAlive(this);
372                 if (ret >= 0 && ret <= 4096) { return null; }
373                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
374                 return ret_conv;
375         }
376
377         /**
378          * Hash that was used for signing the invoice.
379          */
380         public byte[] signable_hash() {
381                 long ret = bindings.Bolt12Invoice_signable_hash(this.ptr);
382                 GC.KeepAlive(this);
383                 if (ret >= 0 && ret <= 4096) { return null; }
384                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
385                 return ret_conv;
386         }
387
388         /**
389          * Verifies that the invoice was for a request or refund created using the given key. Returns
390          * the associated [`PaymentId`] to use when sending the payment.
391          */
392         public Result_ThirtyTwoBytesNoneZ verify(org.ldk.structs.ExpandedKey key) {
393                 long ret = bindings.Bolt12Invoice_verify(this.ptr, key.ptr);
394                 GC.KeepAlive(this);
395                 GC.KeepAlive(key);
396                 if (ret >= 0 && ret <= 4096) { return null; }
397                 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
398                 if (this != null) { this.ptrs_to.AddLast(key); };
399                 return ret_hu_conv;
400         }
401
402         /**
403          * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice.
404          */
405         public long hash() {
406                 long ret = bindings.Bolt12Invoice_hash(this.ptr);
407                 GC.KeepAlive(this);
408                 return ret;
409         }
410
411         public override int GetHashCode() {
412                 return (int)this.hash();
413         }
414         /**
415          * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
416          */
417         public byte[] write() {
418                 long ret = bindings.Bolt12Invoice_write(this.ptr);
419                 GC.KeepAlive(this);
420                 if (ret >= 0 && ret <= 4096) { return null; }
421                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
422                 return ret_conv;
423         }
424
425 }
426 } } }