1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
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.
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 {
21 if (ptr != 0) { bindings.Bolt11ParseError_free(ptr); }
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);
28 if (raw_val.getClass() == bindings.LDKBolt11ParseError.ParseAmountError.class) {
29 return new ParseAmountError(ptr, (bindings.LDKBolt11ParseError.ParseAmountError)raw_val);
31 if (raw_val.getClass() == bindings.LDKBolt11ParseError.MalformedSignature.class) {
32 return new MalformedSignature(ptr, (bindings.LDKBolt11ParseError.MalformedSignature)raw_val);
34 if (raw_val.getClass() == bindings.LDKBolt11ParseError.BadPrefix.class) {
35 return new BadPrefix(ptr, (bindings.LDKBolt11ParseError.BadPrefix)raw_val);
37 if (raw_val.getClass() == bindings.LDKBolt11ParseError.UnknownCurrency.class) {
38 return new UnknownCurrency(ptr, (bindings.LDKBolt11ParseError.UnknownCurrency)raw_val);
40 if (raw_val.getClass() == bindings.LDKBolt11ParseError.UnknownSiPrefix.class) {
41 return new UnknownSiPrefix(ptr, (bindings.LDKBolt11ParseError.UnknownSiPrefix)raw_val);
43 if (raw_val.getClass() == bindings.LDKBolt11ParseError.MalformedHRP.class) {
44 return new MalformedHRP(ptr, (bindings.LDKBolt11ParseError.MalformedHRP)raw_val);
46 if (raw_val.getClass() == bindings.LDKBolt11ParseError.TooShortDataPart.class) {
47 return new TooShortDataPart(ptr, (bindings.LDKBolt11ParseError.TooShortDataPart)raw_val);
49 if (raw_val.getClass() == bindings.LDKBolt11ParseError.UnexpectedEndOfTaggedFields.class) {
50 return new UnexpectedEndOfTaggedFields(ptr, (bindings.LDKBolt11ParseError.UnexpectedEndOfTaggedFields)raw_val);
52 if (raw_val.getClass() == bindings.LDKBolt11ParseError.DescriptionDecodeError.class) {
53 return new DescriptionDecodeError(ptr, (bindings.LDKBolt11ParseError.DescriptionDecodeError)raw_val);
55 if (raw_val.getClass() == bindings.LDKBolt11ParseError.PaddingError.class) {
56 return new PaddingError(ptr, (bindings.LDKBolt11ParseError.PaddingError)raw_val);
58 if (raw_val.getClass() == bindings.LDKBolt11ParseError.IntegerOverflowError.class) {
59 return new IntegerOverflowError(ptr, (bindings.LDKBolt11ParseError.IntegerOverflowError)raw_val);
61 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidSegWitProgramLength.class) {
62 return new InvalidSegWitProgramLength(ptr, (bindings.LDKBolt11ParseError.InvalidSegWitProgramLength)raw_val);
64 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidPubKeyHashLength.class) {
65 return new InvalidPubKeyHashLength(ptr, (bindings.LDKBolt11ParseError.InvalidPubKeyHashLength)raw_val);
67 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidScriptHashLength.class) {
68 return new InvalidScriptHashLength(ptr, (bindings.LDKBolt11ParseError.InvalidScriptHashLength)raw_val);
70 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidRecoveryId.class) {
71 return new InvalidRecoveryId(ptr, (bindings.LDKBolt11ParseError.InvalidRecoveryId)raw_val);
73 if (raw_val.getClass() == bindings.LDKBolt11ParseError.InvalidSliceLength.class) {
74 return new InvalidSliceLength(ptr, (bindings.LDKBolt11ParseError.InvalidSliceLength)raw_val);
76 if (raw_val.getClass() == bindings.LDKBolt11ParseError.Skip.class) {
77 return new Skip(ptr, (bindings.LDKBolt11ParseError.Skip)raw_val);
79 assert false; return null; // Unreachable without extending the (internal) bindings interface
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) {
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;
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) {
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;
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) {
105 this.malformed_signature = obj.malformed_signature;
108 public final static class BadPrefix extends Bolt11ParseError {
109 private BadPrefix(long ptr, bindings.LDKBolt11ParseError.BadPrefix obj) {
113 public final static class UnknownCurrency extends Bolt11ParseError {
114 private UnknownCurrency(long ptr, bindings.LDKBolt11ParseError.UnknownCurrency obj) {
118 public final static class UnknownSiPrefix extends Bolt11ParseError {
119 private UnknownSiPrefix(long ptr, bindings.LDKBolt11ParseError.UnknownSiPrefix obj) {
123 public final static class MalformedHRP extends Bolt11ParseError {
124 private MalformedHRP(long ptr, bindings.LDKBolt11ParseError.MalformedHRP obj) {
128 public final static class TooShortDataPart extends Bolt11ParseError {
129 private TooShortDataPart(long ptr, bindings.LDKBolt11ParseError.TooShortDataPart obj) {
133 public final static class UnexpectedEndOfTaggedFields extends Bolt11ParseError {
134 private UnexpectedEndOfTaggedFields(long ptr, bindings.LDKBolt11ParseError.UnexpectedEndOfTaggedFields obj) {
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) {
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;
147 public final static class PaddingError extends Bolt11ParseError {
148 private PaddingError(long ptr, bindings.LDKBolt11ParseError.PaddingError obj) {
152 public final static class IntegerOverflowError extends Bolt11ParseError {
153 private IntegerOverflowError(long ptr, bindings.LDKBolt11ParseError.IntegerOverflowError obj) {
157 public final static class InvalidSegWitProgramLength extends Bolt11ParseError {
158 private InvalidSegWitProgramLength(long ptr, bindings.LDKBolt11ParseError.InvalidSegWitProgramLength obj) {
162 public final static class InvalidPubKeyHashLength extends Bolt11ParseError {
163 private InvalidPubKeyHashLength(long ptr, bindings.LDKBolt11ParseError.InvalidPubKeyHashLength obj) {
167 public final static class InvalidScriptHashLength extends Bolt11ParseError {
168 private InvalidScriptHashLength(long ptr, bindings.LDKBolt11ParseError.InvalidScriptHashLength obj) {
172 public final static class InvalidRecoveryId extends Bolt11ParseError {
173 private InvalidRecoveryId(long ptr, bindings.LDKBolt11ParseError.InvalidRecoveryId obj) {
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) {
181 this.invalid_slice_length = obj.invalid_slice_length;
185 * Not an error, but used internally to signal that a part of the invoice should be ignored
186 * according to BOLT11
188 public final static class Skip extends Bolt11ParseError {
189 private Skip(long ptr, bindings.LDKBolt11ParseError.Skip obj) {
194 long ret = bindings.Bolt11ParseError_clone_ptr(this.ptr);
195 Reference.reachabilityFence(this);
200 * Creates a copy of the Bolt11ParseError
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); };
212 * Utility method to constructs a new Bech32Error-variant Bolt11ParseError
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); };
225 * Utility method to constructs a new ParseAmountError-variant Bolt11ParseError
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); };
237 * Utility method to constructs a new MalformedSignature-variant Bolt11ParseError
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); };
249 * Utility method to constructs a new BadPrefix-variant Bolt11ParseError
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); };
260 * Utility method to constructs a new UnknownCurrency-variant Bolt11ParseError
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); };
271 * Utility method to constructs a new UnknownSiPrefix-variant Bolt11ParseError
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); };
282 * Utility method to constructs a new MalformedHRP-variant Bolt11ParseError
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); };
293 * Utility method to constructs a new TooShortDataPart-variant Bolt11ParseError
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); };
304 * Utility method to constructs a new UnexpectedEndOfTaggedFields-variant Bolt11ParseError
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); };
315 * Utility method to constructs a new DescriptionDecodeError-variant Bolt11ParseError
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); };
327 * Utility method to constructs a new PaddingError-variant Bolt11ParseError
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); };
338 * Utility method to constructs a new IntegerOverflowError-variant Bolt11ParseError
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); };
349 * Utility method to constructs a new InvalidSegWitProgramLength-variant Bolt11ParseError
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); };
360 * Utility method to constructs a new InvalidPubKeyHashLength-variant Bolt11ParseError
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); };
371 * Utility method to constructs a new InvalidScriptHashLength-variant Bolt11ParseError
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); };
382 * Utility method to constructs a new InvalidRecoveryId-variant Bolt11ParseError
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); };
393 * Utility method to constructs a new InvalidSliceLength-variant Bolt11ParseError
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); };
405 * Utility method to constructs a new Skip-variant Bolt11ParseError
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); };
416 * Checks if two Bolt11ParseErrors contain equal inner contents.
417 * This ignores pointers and is_owned flags and looks at the values in fields.
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);
426 @Override public boolean equals(Object o) {
427 if (!(o instanceof Bolt11ParseError)) return false;
428 return this.eq((Bolt11ParseError)o);
431 * Get the string representation of a Bolt11ParseError object
433 public String to_str() {
434 String ret = bindings.Bolt11ParseError_to_str(this.ptr);
435 Reference.reachabilityFence(this);