[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / Offer.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 `Offer` is a potentially long-lived proposal for payment of a good or service.
11  * 
12  * An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a
13  * customer may request an [`Bolt12Invoice`] for a specific quantity and using an amount sufficient
14  * to cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`].
15  * 
16  * Offers may be denominated in currency other than bitcoin but are ultimately paid using the
17  * latter.
18  * 
19  * Through the use of [`BlindedPath`]s, offers provide recipient privacy.
20  * 
21  * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
22  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
23  */
24 public class Offer : CommonBase {
25         internal Offer(object _dummy, long ptr) : base(ptr) { }
26         ~Offer() {
27                 if (ptr != 0) { bindings.Offer_free(ptr); }
28         }
29
30         internal long clone_ptr() {
31                 long ret = bindings.Offer_clone_ptr(this.ptr);
32                 GC.KeepAlive(this);
33                 return ret;
34         }
35
36         /**
37          * Creates a copy of the Offer
38          */
39         public Offer clone() {
40                 long ret = bindings.Offer_clone(this.ptr);
41                 GC.KeepAlive(this);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 org.ldk.structs.Offer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Offer(null, ret); }
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
45                 return ret_hu_conv;
46         }
47
48         /**
49          * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
50          * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
51          * for the selected chain.
52          */
53         public byte[][] chains() {
54                 byte[][] ret = bindings.Offer_chains(this.ptr);
55                 GC.KeepAlive(this);
56                 return ret;
57         }
58
59         /**
60          * Returns whether the given chain is supported by the offer.
61          */
62         public bool supports_chain(byte[] chain) {
63                 bool ret = bindings.Offer_supports_chain(this.ptr, InternalUtils.check_arr_len(chain, 32));
64                 GC.KeepAlive(this);
65                 GC.KeepAlive(chain);
66                 return ret;
67         }
68
69         /**
70          * Opaque bytes set by the originator. Useful for authentication and validating fields since it
71          * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
72          */
73         public Option_CVec_u8ZZ metadata() {
74                 long ret = bindings.Offer_metadata(this.ptr);
75                 GC.KeepAlive(this);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
79                 return ret_hu_conv;
80         }
81
82         /**
83          * The minimum amount required for a successful payment of a single item.
84          * 
85          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
86          */
87         public Amount amount() {
88                 long ret = bindings.Offer_amount(this.ptr);
89                 GC.KeepAlive(this);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * A complete description of the purpose of the payment. Intended to be displayed to the user
98          * but with the caveat that it has not been verified in any way.
99          */
100         public PrintableString description() {
101                 long ret = bindings.Offer_description(this.ptr);
102                 GC.KeepAlive(this);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Features pertaining to the offer.
111          */
112         public OfferFeatures features() {
113                 long ret = bindings.Offer_features(this.ptr);
114                 GC.KeepAlive(this);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Duration since the Unix epoch when an invoice should no longer be requested.
123          * 
124          * If `None`, the offer does not expire.
125          */
126         public Option_DurationZ absolute_expiry() {
127                 long ret = bindings.Offer_absolute_expiry(this.ptr);
128                 GC.KeepAlive(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 org.ldk.structs.Option_DurationZ ret_hu_conv = org.ldk.structs.Option_DurationZ.constr_from_ptr(ret);
131                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Whether the offer has expired.
137          */
138         public bool is_expired() {
139                 bool ret = bindings.Offer_is_expired(this.ptr);
140                 GC.KeepAlive(this);
141                 return ret;
142         }
143
144         /**
145          * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
146          * displayed to the user but with the caveat that it has not been verified in any way.
147          * 
148          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
149          */
150         public PrintableString issuer() {
151                 long ret = bindings.Offer_issuer(this.ptr);
152                 GC.KeepAlive(this);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
156                 return ret_hu_conv;
157         }
158
159         /**
160          * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
161          * recipient privacy by obfuscating its node id.
162          */
163         public BlindedPath[] paths() {
164                 long[] ret = bindings.Offer_paths(this.ptr);
165                 GC.KeepAlive(this);
166                 int ret_conv_13_len = ret.Length;
167                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
168                 for (int n = 0; n < ret_conv_13_len; n++) {
169                         long ret_conv_13 = ret[n];
170                         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); }
171                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
172                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
173                 }
174                 return ret_conv_13_arr;
175         }
176
177         /**
178          * The quantity of items supported.
179          */
180         public Quantity supported_quantity() {
181                 long ret = bindings.Offer_supported_quantity(this.ptr);
182                 GC.KeepAlive(this);
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
186                 return ret_hu_conv;
187         }
188
189         /**
190          * Returns whether the given quantity is valid for the offer.
191          */
192         public bool is_valid_quantity(long quantity) {
193                 bool ret = bindings.Offer_is_valid_quantity(this.ptr, quantity);
194                 GC.KeepAlive(this);
195                 GC.KeepAlive(quantity);
196                 return ret;
197         }
198
199         /**
200          * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer.
201          * 
202          * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
203          */
204         public bool expects_quantity() {
205                 bool ret = bindings.Offer_expects_quantity(this.ptr);
206                 GC.KeepAlive(this);
207                 return ret;
208         }
209
210         /**
211          * The public key used by the recipient to sign invoices.
212          */
213         public byte[] signing_pubkey() {
214                 byte[] ret = bindings.Offer_signing_pubkey(this.ptr);
215                 GC.KeepAlive(this);
216                 return ret;
217         }
218
219         /**
220          * Serialize the Offer object into a byte array which can be read by Offer_read
221          */
222         public byte[] write() {
223                 byte[] ret = bindings.Offer_write(this.ptr);
224                 GC.KeepAlive(this);
225                 return ret;
226         }
227
228         /**
229          * Read a Offer object from a string
230          */
231         public static Result_OfferBolt12ParseErrorZ from_str(string s) {
232                 long ret = bindings.Offer_from_str(s);
233                 GC.KeepAlive(s);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 Result_OfferBolt12ParseErrorZ ret_hu_conv = Result_OfferBolt12ParseErrorZ.constr_from_ptr(ret);
236                 return ret_hu_conv;
237         }
238
239 }
240 } } }