[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / Bolt11ParseError.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Errors that indicate what is wrong with the invoice. They have some granularity for debug
13  * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class Bolt11ParseError extends CommonBase {
17         private Bolt11ParseError(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.Bolt11ParseError_free(ptr); }
22         }
23         static Bolt11ParseError constr_from_ptr(long ptr) {
24                 bindings.LDKBolt11ParseError raw_val = bindings.LDKBolt11ParseError_ref_from_ptr(ptr);
25                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.Bech32Error.class) {
26                         return new Bech32Error(ptr, (bindings.LDKBolt11ParseError.Bech32Error)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.ParseAmountError.class) {
29                         return new ParseAmountError(ptr, (bindings.LDKBolt11ParseError.ParseAmountError)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.MalformedSignature.class) {
32                         return new MalformedSignature(ptr, (bindings.LDKBolt11ParseError.MalformedSignature)raw_val);
33                 }
34                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.BadPrefix.class) {
35                         return new BadPrefix(ptr, (bindings.LDKBolt11ParseError.BadPrefix)raw_val);
36                 }
37                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.UnknownCurrency.class) {
38                         return new UnknownCurrency(ptr, (bindings.LDKBolt11ParseError.UnknownCurrency)raw_val);
39                 }
40                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.UnknownSiPrefix.class) {
41                         return new UnknownSiPrefix(ptr, (bindings.LDKBolt11ParseError.UnknownSiPrefix)raw_val);
42                 }
43                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.MalformedHRP.class) {
44                         return new MalformedHRP(ptr, (bindings.LDKBolt11ParseError.MalformedHRP)raw_val);
45                 }
46                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.TooShortDataPart.class) {
47                         return new TooShortDataPart(ptr, (bindings.LDKBolt11ParseError.TooShortDataPart)raw_val);
48                 }
49                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.UnexpectedEndOfTaggedFields.class) {
50                         return new UnexpectedEndOfTaggedFields(ptr, (bindings.LDKBolt11ParseError.UnexpectedEndOfTaggedFields)raw_val);
51                 }
52                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.DescriptionDecodeError.class) {
53                         return new DescriptionDecodeError(ptr, (bindings.LDKBolt11ParseError.DescriptionDecodeError)raw_val);
54                 }
55                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.PaddingError.class) {
56                         return new PaddingError(ptr, (bindings.LDKBolt11ParseError.PaddingError)raw_val);
57                 }
58                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.IntegerOverflowError.class) {
59                         return new IntegerOverflowError(ptr, (bindings.LDKBolt11ParseError.IntegerOverflowError)raw_val);
60                 }
61                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidSegWitProgramLength.class) {
62                         return new InvalidSegWitProgramLength(ptr, (bindings.LDKBolt11ParseError.InvalidSegWitProgramLength)raw_val);
63                 }
64                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidPubKeyHashLength.class) {
65                         return new InvalidPubKeyHashLength(ptr, (bindings.LDKBolt11ParseError.InvalidPubKeyHashLength)raw_val);
66                 }
67                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidScriptHashLength.class) {
68                         return new InvalidScriptHashLength(ptr, (bindings.LDKBolt11ParseError.InvalidScriptHashLength)raw_val);
69                 }
70                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidRecoveryId.class) {
71                         return new InvalidRecoveryId(ptr, (bindings.LDKBolt11ParseError.InvalidRecoveryId)raw_val);
72                 }
73                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidSliceLength.class) {
74                         return new InvalidSliceLength(ptr, (bindings.LDKBolt11ParseError.InvalidSliceLength)raw_val);
75                 }
76                 if (raw_val.getClass() == bindings.LDKBolt11ParseError.Skip.class) {
77                         return new Skip(ptr, (bindings.LDKBolt11ParseError.Skip)raw_val);
78                 }
79                 assert false; return null; // Unreachable without extending the (internal) bindings interface
80         }
81
82         public final static class Bech32Error extends Bolt11ParseError {
83                 public final org.ldk.structs.Bech32Error bech32_error;
84                 private Bech32Error(long ptr, bindings.LDKBolt11ParseError.Bech32Error obj) {
85                         super(null, ptr);
86                         long bech32_error = obj.bech32_error;
87                         org.ldk.structs.Bech32Error bech32_error_hu_conv = org.ldk.structs.Bech32Error.constr_from_ptr(bech32_error);
88                         if (bech32_error_hu_conv != null) { bech32_error_hu_conv.ptrs_to.add(this); };
89                         this.bech32_error = bech32_error_hu_conv;
90                 }
91         }
92         public final static class ParseAmountError extends Bolt11ParseError {
93                 public final org.ldk.util.UnqualifiedError parse_amount_error;
94                 private ParseAmountError(long ptr, bindings.LDKBolt11ParseError.ParseAmountError obj) {
95                         super(null, ptr);
96                         int parse_amount_error = obj.parse_amount_error;
97                         UnqualifiedError parse_amount_error_conv = new UnqualifiedError(parse_amount_error);
98                         this.parse_amount_error = parse_amount_error_conv;
99                 }
100         }
101         public final static class MalformedSignature extends Bolt11ParseError {
102                 public final org.ldk.enums.Secp256k1Error malformed_signature;
103                 private MalformedSignature(long ptr, bindings.LDKBolt11ParseError.MalformedSignature obj) {
104                         super(null, ptr);
105                         this.malformed_signature = obj.malformed_signature;
106                 }
107         }
108         public final static class BadPrefix extends Bolt11ParseError {
109                 private BadPrefix(long ptr, bindings.LDKBolt11ParseError.BadPrefix obj) {
110                         super(null, ptr);
111                 }
112         }
113         public final static class UnknownCurrency extends Bolt11ParseError {
114                 private UnknownCurrency(long ptr, bindings.LDKBolt11ParseError.UnknownCurrency obj) {
115                         super(null, ptr);
116                 }
117         }
118         public final static class UnknownSiPrefix extends Bolt11ParseError {
119                 private UnknownSiPrefix(long ptr, bindings.LDKBolt11ParseError.UnknownSiPrefix obj) {
120                         super(null, ptr);
121                 }
122         }
123         public final static class MalformedHRP extends Bolt11ParseError {
124                 private MalformedHRP(long ptr, bindings.LDKBolt11ParseError.MalformedHRP obj) {
125                         super(null, ptr);
126                 }
127         }
128         public final static class TooShortDataPart extends Bolt11ParseError {
129                 private TooShortDataPart(long ptr, bindings.LDKBolt11ParseError.TooShortDataPart obj) {
130                         super(null, ptr);
131                 }
132         }
133         public final static class UnexpectedEndOfTaggedFields extends Bolt11ParseError {
134                 private UnexpectedEndOfTaggedFields(long ptr, bindings.LDKBolt11ParseError.UnexpectedEndOfTaggedFields obj) {
135                         super(null, ptr);
136                 }
137         }
138         public final static class DescriptionDecodeError extends Bolt11ParseError {
139                 public final org.ldk.util.UnqualifiedError description_decode_error;
140                 private DescriptionDecodeError(long ptr, bindings.LDKBolt11ParseError.DescriptionDecodeError obj) {
141                         super(null, ptr);
142                         int description_decode_error = obj.description_decode_error;
143                         UnqualifiedError description_decode_error_conv = new UnqualifiedError(description_decode_error);
144                         this.description_decode_error = description_decode_error_conv;
145                 }
146         }
147         public final static class PaddingError extends Bolt11ParseError {
148                 private PaddingError(long ptr, bindings.LDKBolt11ParseError.PaddingError obj) {
149                         super(null, ptr);
150                 }
151         }
152         public final static class IntegerOverflowError extends Bolt11ParseError {
153                 private IntegerOverflowError(long ptr, bindings.LDKBolt11ParseError.IntegerOverflowError obj) {
154                         super(null, ptr);
155                 }
156         }
157         public final static class InvalidSegWitProgramLength extends Bolt11ParseError {
158                 private InvalidSegWitProgramLength(long ptr, bindings.LDKBolt11ParseError.InvalidSegWitProgramLength obj) {
159                         super(null, ptr);
160                 }
161         }
162         public final static class InvalidPubKeyHashLength extends Bolt11ParseError {
163                 private InvalidPubKeyHashLength(long ptr, bindings.LDKBolt11ParseError.InvalidPubKeyHashLength obj) {
164                         super(null, ptr);
165                 }
166         }
167         public final static class InvalidScriptHashLength extends Bolt11ParseError {
168                 private InvalidScriptHashLength(long ptr, bindings.LDKBolt11ParseError.InvalidScriptHashLength obj) {
169                         super(null, ptr);
170                 }
171         }
172         public final static class InvalidRecoveryId extends Bolt11ParseError {
173                 private InvalidRecoveryId(long ptr, bindings.LDKBolt11ParseError.InvalidRecoveryId obj) {
174                         super(null, ptr);
175                 }
176         }
177         public final static class InvalidSliceLength extends Bolt11ParseError {
178                 public final java.lang.String invalid_slice_length;
179                 private InvalidSliceLength(long ptr, bindings.LDKBolt11ParseError.InvalidSliceLength obj) {
180                         super(null, ptr);
181                         this.invalid_slice_length = obj.invalid_slice_length;
182                 }
183         }
184         /**
185          * Not an error, but used internally to signal that a part of the invoice should be ignored
186          * according to BOLT11
187          */
188         public final static class Skip extends Bolt11ParseError {
189                 private Skip(long ptr, bindings.LDKBolt11ParseError.Skip obj) {
190                         super(null, ptr);
191                 }
192         }
193         long clone_ptr() {
194                 long ret = bindings.Bolt11ParseError_clone_ptr(this.ptr);
195                 Reference.reachabilityFence(this);
196                 return ret;
197         }
198
199         /**
200          * Creates a copy of the Bolt11ParseError
201          */
202         public Bolt11ParseError clone() {
203                 long ret = bindings.Bolt11ParseError_clone(this.ptr);
204                 Reference.reachabilityFence(this);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
207                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
208                 return ret_hu_conv;
209         }
210
211         /**
212          * Utility method to constructs a new Bech32Error-variant Bolt11ParseError
213          */
214         public static Bolt11ParseError bech32_error(org.ldk.structs.Bech32Error a) {
215                 long ret = bindings.Bolt11ParseError_bech32_error(a.ptr);
216                 Reference.reachabilityFence(a);
217                 if (ret >= 0 && ret <= 4096) { return null; }
218                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
219                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
220                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
221                 return ret_hu_conv;
222         }
223
224         /**
225          * Utility method to constructs a new ParseAmountError-variant Bolt11ParseError
226          */
227         public static Bolt11ParseError parse_amount_error(org.ldk.util.UnqualifiedError a) {
228                 long ret = bindings.Bolt11ParseError_parse_amount_error(0);
229                 Reference.reachabilityFence(a);
230                 if (ret >= 0 && ret <= 4096) { return null; }
231                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
232                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
233                 return ret_hu_conv;
234         }
235
236         /**
237          * Utility method to constructs a new MalformedSignature-variant Bolt11ParseError
238          */
239         public static Bolt11ParseError malformed_signature(org.ldk.enums.Secp256k1Error a) {
240                 long ret = bindings.Bolt11ParseError_malformed_signature(a);
241                 Reference.reachabilityFence(a);
242                 if (ret >= 0 && ret <= 4096) { return null; }
243                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
244                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
245                 return ret_hu_conv;
246         }
247
248         /**
249          * Utility method to constructs a new BadPrefix-variant Bolt11ParseError
250          */
251         public static Bolt11ParseError bad_prefix() {
252                 long ret = bindings.Bolt11ParseError_bad_prefix();
253                 if (ret >= 0 && ret <= 4096) { return null; }
254                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
255                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
256                 return ret_hu_conv;
257         }
258
259         /**
260          * Utility method to constructs a new UnknownCurrency-variant Bolt11ParseError
261          */
262         public static Bolt11ParseError unknown_currency() {
263                 long ret = bindings.Bolt11ParseError_unknown_currency();
264                 if (ret >= 0 && ret <= 4096) { return null; }
265                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
266                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
267                 return ret_hu_conv;
268         }
269
270         /**
271          * Utility method to constructs a new UnknownSiPrefix-variant Bolt11ParseError
272          */
273         public static Bolt11ParseError unknown_si_prefix() {
274                 long ret = bindings.Bolt11ParseError_unknown_si_prefix();
275                 if (ret >= 0 && ret <= 4096) { return null; }
276                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
277                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
278                 return ret_hu_conv;
279         }
280
281         /**
282          * Utility method to constructs a new MalformedHRP-variant Bolt11ParseError
283          */
284         public static Bolt11ParseError malformed_hrp() {
285                 long ret = bindings.Bolt11ParseError_malformed_hrp();
286                 if (ret >= 0 && ret <= 4096) { return null; }
287                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
288                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
289                 return ret_hu_conv;
290         }
291
292         /**
293          * Utility method to constructs a new TooShortDataPart-variant Bolt11ParseError
294          */
295         public static Bolt11ParseError too_short_data_part() {
296                 long ret = bindings.Bolt11ParseError_too_short_data_part();
297                 if (ret >= 0 && ret <= 4096) { return null; }
298                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
299                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
300                 return ret_hu_conv;
301         }
302
303         /**
304          * Utility method to constructs a new UnexpectedEndOfTaggedFields-variant Bolt11ParseError
305          */
306         public static Bolt11ParseError unexpected_end_of_tagged_fields() {
307                 long ret = bindings.Bolt11ParseError_unexpected_end_of_tagged_fields();
308                 if (ret >= 0 && ret <= 4096) { return null; }
309                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
310                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
311                 return ret_hu_conv;
312         }
313
314         /**
315          * Utility method to constructs a new DescriptionDecodeError-variant Bolt11ParseError
316          */
317         public static Bolt11ParseError description_decode_error(org.ldk.util.UnqualifiedError a) {
318                 long ret = bindings.Bolt11ParseError_description_decode_error(0);
319                 Reference.reachabilityFence(a);
320                 if (ret >= 0 && ret <= 4096) { return null; }
321                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
322                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
323                 return ret_hu_conv;
324         }
325
326         /**
327          * Utility method to constructs a new PaddingError-variant Bolt11ParseError
328          */
329         public static Bolt11ParseError padding_error() {
330                 long ret = bindings.Bolt11ParseError_padding_error();
331                 if (ret >= 0 && ret <= 4096) { return null; }
332                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
333                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
334                 return ret_hu_conv;
335         }
336
337         /**
338          * Utility method to constructs a new IntegerOverflowError-variant Bolt11ParseError
339          */
340         public static Bolt11ParseError integer_overflow_error() {
341                 long ret = bindings.Bolt11ParseError_integer_overflow_error();
342                 if (ret >= 0 && ret <= 4096) { return null; }
343                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
344                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
345                 return ret_hu_conv;
346         }
347
348         /**
349          * Utility method to constructs a new InvalidSegWitProgramLength-variant Bolt11ParseError
350          */
351         public static Bolt11ParseError invalid_seg_wit_program_length() {
352                 long ret = bindings.Bolt11ParseError_invalid_seg_wit_program_length();
353                 if (ret >= 0 && ret <= 4096) { return null; }
354                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
355                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
356                 return ret_hu_conv;
357         }
358
359         /**
360          * Utility method to constructs a new InvalidPubKeyHashLength-variant Bolt11ParseError
361          */
362         public static Bolt11ParseError invalid_pub_key_hash_length() {
363                 long ret = bindings.Bolt11ParseError_invalid_pub_key_hash_length();
364                 if (ret >= 0 && ret <= 4096) { return null; }
365                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
366                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
367                 return ret_hu_conv;
368         }
369
370         /**
371          * Utility method to constructs a new InvalidScriptHashLength-variant Bolt11ParseError
372          */
373         public static Bolt11ParseError invalid_script_hash_length() {
374                 long ret = bindings.Bolt11ParseError_invalid_script_hash_length();
375                 if (ret >= 0 && ret <= 4096) { return null; }
376                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
377                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
378                 return ret_hu_conv;
379         }
380
381         /**
382          * Utility method to constructs a new InvalidRecoveryId-variant Bolt11ParseError
383          */
384         public static Bolt11ParseError invalid_recovery_id() {
385                 long ret = bindings.Bolt11ParseError_invalid_recovery_id();
386                 if (ret >= 0 && ret <= 4096) { return null; }
387                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
388                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
389                 return ret_hu_conv;
390         }
391
392         /**
393          * Utility method to constructs a new InvalidSliceLength-variant Bolt11ParseError
394          */
395         public static Bolt11ParseError invalid_slice_length(java.lang.String a) {
396                 long ret = bindings.Bolt11ParseError_invalid_slice_length(a);
397                 Reference.reachabilityFence(a);
398                 if (ret >= 0 && ret <= 4096) { return null; }
399                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
400                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
401                 return ret_hu_conv;
402         }
403
404         /**
405          * Utility method to constructs a new Skip-variant Bolt11ParseError
406          */
407         public static Bolt11ParseError skip() {
408                 long ret = bindings.Bolt11ParseError_skip();
409                 if (ret >= 0 && ret <= 4096) { return null; }
410                 org.ldk.structs.Bolt11ParseError ret_hu_conv = org.ldk.structs.Bolt11ParseError.constr_from_ptr(ret);
411                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
412                 return ret_hu_conv;
413         }
414
415         /**
416          * Checks if two Bolt11ParseErrors contain equal inner contents.
417          * This ignores pointers and is_owned flags and looks at the values in fields.
418          */
419         public boolean eq(org.ldk.structs.Bolt11ParseError b) {
420                 boolean ret = bindings.Bolt11ParseError_eq(this.ptr, b == null ? 0 : b.ptr);
421                 Reference.reachabilityFence(this);
422                 Reference.reachabilityFence(b);
423                 return ret;
424         }
425
426         @Override public boolean equals(Object o) {
427                 if (!(o instanceof Bolt11ParseError)) return false;
428                 return this.eq((Bolt11ParseError)o);
429         }
430         /**
431          * Get the string representation of a Bolt11ParseError object
432          */
433         public String to_str() {
434                 String ret = bindings.Bolt11ParseError_to_str(this.ptr);
435                 Reference.reachabilityFence(this);
436                 return ret;
437         }
438
439 }