[C#] Update auto-generated files
[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          * A complete description of the purpose of the originating offer or refund. Intended to be
45          * displayed to the user but with the caveat that it has not been verified in any way.
46          */
47         public PrintableString description() {
48                 long ret = bindings.Bolt12Invoice_description(this.ptr);
49                 GC.KeepAlive(this);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
52                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Duration since the Unix epoch when the invoice was created.
58          */
59         public long created_at() {
60                 long ret = bindings.Bolt12Invoice_created_at(this.ptr);
61                 GC.KeepAlive(this);
62                 return ret;
63         }
64
65         /**
66          * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
67          * should no longer be paid.
68          */
69         public long relative_expiry() {
70                 long ret = bindings.Bolt12Invoice_relative_expiry(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * Whether the invoice has expired.
77          */
78         public bool is_expired() {
79                 bool ret = bindings.Bolt12Invoice_is_expired(this.ptr);
80                 GC.KeepAlive(this);
81                 return ret;
82         }
83
84         /**
85          * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
86          */
87         public byte[] payment_hash() {
88                 byte[] ret = bindings.Bolt12Invoice_payment_hash(this.ptr);
89                 GC.KeepAlive(this);
90                 return ret;
91         }
92
93         /**
94          * The minimum amount required for a successful payment of the invoice.
95          */
96         public long amount_msats() {
97                 long ret = bindings.Bolt12Invoice_amount_msats(this.ptr);
98                 GC.KeepAlive(this);
99                 return ret;
100         }
101
102         /**
103          * Features pertaining to paying an invoice.
104          */
105         public Bolt12InvoiceFeatures features() {
106                 long ret = bindings.Bolt12Invoice_features(this.ptr);
107                 GC.KeepAlive(this);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * The public key corresponding to the key used to sign the invoice.
116          */
117         public byte[] signing_pubkey() {
118                 byte[] ret = bindings.Bolt12Invoice_signing_pubkey(this.ptr);
119                 GC.KeepAlive(this);
120                 return ret;
121         }
122
123         /**
124          * Hash that was used for signing the invoice.
125          */
126         public byte[] signable_hash() {
127                 byte[] ret = bindings.Bolt12Invoice_signable_hash(this.ptr);
128                 GC.KeepAlive(this);
129                 return ret;
130         }
131
132         /**
133          * Verifies that the invoice was for a request or refund created using the given key.
134          */
135         public bool verify(org.ldk.structs.ExpandedKey key) {
136                 bool ret = bindings.Bolt12Invoice_verify(this.ptr, key == null ? 0 : key.ptr);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(key);
139                 if (this != null) { this.ptrs_to.AddLast(key); };
140                 return ret;
141         }
142
143         /**
144          * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
145          */
146         public byte[] write() {
147                 byte[] ret = bindings.Bolt12Invoice_write(this.ptr);
148                 GC.KeepAlive(this);
149                 return ret;
150         }
151
152 }
153 } } }