[Java] Print error stack trace when tests fail
[ldk-java] / c_sharp / src / org / ldk / structs / UnsignedInvoiceRequest.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 semantically valid [`InvoiceRequest`] that hasn't been signed.
11  * 
12  * # Serialization
13  * 
14  * This is serialized as a TLV stream, which includes TLV records from the originating message. As
15  * such, it may include unknown, odd TLV records.
16  */
17 public class UnsignedInvoiceRequest : CommonBase {
18         internal UnsignedInvoiceRequest(object _dummy, long ptr) : base(ptr) { }
19         ~UnsignedInvoiceRequest() {
20                 if (ptr != 0) { bindings.UnsignedInvoiceRequest_free(ptr); }
21         }
22
23         internal long clone_ptr() {
24                 long ret = bindings.UnsignedInvoiceRequest_clone_ptr(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * Creates a copy of the UnsignedInvoiceRequest
31          */
32         public UnsignedInvoiceRequest clone() {
33                 long ret = bindings.UnsignedInvoiceRequest_clone(this.ptr);
34                 GC.KeepAlive(this);
35                 if (ret >= 0 && ret <= 4096) { return null; }
36                 org.ldk.structs.UnsignedInvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedInvoiceRequest(null, ret); }
37                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Returns the [`TaggedHash`] of the invoice to sign.
43          */
44         public TaggedHash tagged_hash() {
45                 long ret = bindings.UnsignedInvoiceRequest_tagged_hash(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.TaggedHash ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TaggedHash(null, ret); }
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
50                 return ret_hu_conv;
51         }
52
53         /**
54          * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
55          * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
56          * for the selected chain.
57          */
58         public byte[][] chains() {
59                 long ret = bindings.UnsignedInvoiceRequest_chains(this.ptr);
60                 GC.KeepAlive(this);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
63                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
64                 for (int i = 0; i < ret_conv_8_len; i++) {
65                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
66                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
67                         ret_conv_8_arr[i] = ret_conv_8_conv;
68                 }
69                 bindings.free_buffer(ret);
70                 return ret_conv_8_arr;
71         }
72
73         /**
74          * Opaque bytes set by the originator. Useful for authentication and validating fields since it
75          * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
76          */
77         public Option_CVec_u8ZZ metadata() {
78                 long ret = bindings.UnsignedInvoiceRequest_metadata(this.ptr);
79                 GC.KeepAlive(this);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * The minimum amount required for a successful payment of a single item.
88          */
89         public Option_AmountZ amount() {
90                 long ret = bindings.UnsignedInvoiceRequest_amount(this.ptr);
91                 GC.KeepAlive(this);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95                 return ret_hu_conv;
96         }
97
98         /**
99          * A complete description of the purpose of the payment. Intended to be displayed to the user
100          * but with the caveat that it has not been verified in any way.
101          * 
102          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
103          */
104         public PrintableString description() {
105                 long ret = bindings.UnsignedInvoiceRequest_description(this.ptr);
106                 GC.KeepAlive(this);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Features pertaining to the offer.
115          */
116         public OfferFeatures offer_features() {
117                 long ret = bindings.UnsignedInvoiceRequest_offer_features(this.ptr);
118                 GC.KeepAlive(this);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Duration since the Unix epoch when an invoice should no longer be requested.
127          * 
128          * If `None`, the offer does not expire.
129          */
130         public Option_u64Z absolute_expiry() {
131                 long ret = bindings.UnsignedInvoiceRequest_absolute_expiry(this.ptr);
132                 GC.KeepAlive(this);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
136                 return ret_hu_conv;
137         }
138
139         /**
140          * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
141          * displayed to the user but with the caveat that it has not been verified in any way.
142          * 
143          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
144          */
145         public PrintableString issuer() {
146                 long ret = bindings.UnsignedInvoiceRequest_issuer(this.ptr);
147                 GC.KeepAlive(this);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
150                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
151                 return ret_hu_conv;
152         }
153
154         /**
155          * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
156          * recipient privacy by obfuscating its node id.
157          */
158         public BlindedPath[] paths() {
159                 long ret = bindings.UnsignedInvoiceRequest_paths(this.ptr);
160                 GC.KeepAlive(this);
161                 if (ret >= 0 && ret <= 4096) { return null; }
162                 int ret_conv_13_len = InternalUtils.getArrayLength(ret);
163                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
164                 for (int n = 0; n < ret_conv_13_len; n++) {
165                         long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
166                         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); }
167                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
168                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
169                 }
170                 bindings.free_buffer(ret);
171                 return ret_conv_13_arr;
172         }
173
174         /**
175          * The quantity of items supported.
176          */
177         public Quantity supported_quantity() {
178                 long ret = bindings.UnsignedInvoiceRequest_supported_quantity(this.ptr);
179                 GC.KeepAlive(this);
180                 if (ret >= 0 && ret <= 4096) { return null; }
181                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
182                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
183                 return ret_hu_conv;
184         }
185
186         /**
187          * The public key used by the recipient to sign invoices.
188          * 
189          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
190          */
191         public byte[] signing_pubkey() {
192                 long ret = bindings.UnsignedInvoiceRequest_signing_pubkey(this.ptr);
193                 GC.KeepAlive(this);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
196                 return ret_conv;
197         }
198
199         /**
200          * An unpredictable series of bytes, typically containing information about the derivation of
201          * [`payer_id`].
202          * 
203          * [`payer_id`]: Self::payer_id
204          */
205         public byte[] payer_metadata() {
206                 long ret = bindings.UnsignedInvoiceRequest_payer_metadata(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          * A chain from [`Offer::chains`] that the offer is valid for.
215          */
216         public byte[] chain() {
217                 long ret = bindings.UnsignedInvoiceRequest_chain(this.ptr);
218                 GC.KeepAlive(this);
219                 if (ret >= 0 && ret <= 4096) { return null; }
220                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
221                 return ret_conv;
222         }
223
224         /**
225          * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
226          * must be greater than or equal to [`Offer::amount`], converted if necessary.
227          * 
228          * [`chain`]: Self::chain
229          */
230         public Option_u64Z amount_msats() {
231                 long ret = bindings.UnsignedInvoiceRequest_amount_msats(this.ptr);
232                 GC.KeepAlive(this);
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
236                 return ret_hu_conv;
237         }
238
239         /**
240          * Features pertaining to requesting an invoice.
241          */
242         public InvoiceRequestFeatures invoice_request_features() {
243                 long ret = bindings.UnsignedInvoiceRequest_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 the offer's item conforming to [`Offer::is_valid_quantity`].
253          */
254         public Option_u64Z quantity() {
255                 long ret = bindings.UnsignedInvoiceRequest_quantity(this.ptr);
256                 GC.KeepAlive(this);
257                 if (ret >= 0 && ret <= 4096) { return null; }
258                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
259                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
260                 return ret_hu_conv;
261         }
262
263         /**
264          * A possibly transient pubkey used to sign the invoice request.
265          */
266         public byte[] payer_id() {
267                 long ret = bindings.UnsignedInvoiceRequest_payer_id(this.ptr);
268                 GC.KeepAlive(this);
269                 if (ret >= 0 && ret <= 4096) { return null; }
270                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
271                 return ret_conv;
272         }
273
274         /**
275          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
276          * response.
277          * 
278          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
279          */
280         public PrintableString payer_note() {
281                 long ret = bindings.UnsignedInvoiceRequest_payer_note(this.ptr);
282                 GC.KeepAlive(this);
283                 if (ret >= 0 && ret <= 4096) { return null; }
284                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
285                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
286                 return ret_hu_conv;
287         }
288
289         /**
290          * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
291          */
292         public byte[] write() {
293                 long ret = bindings.UnsignedInvoiceRequest_write(this.ptr);
294                 GC.KeepAlive(this);
295                 if (ret >= 0 && ret <= 4096) { return null; }
296                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
297                 return ret_conv;
298         }
299
300 }
301 } } }