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 * Indicates that something went wrong while parsing or validating the invoice. Parsing errors
13 * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors
14 * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ParseOrSemanticError extends CommonBase {
18 private ParseOrSemanticError(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.ParseOrSemanticError_free(ptr); }
24 static ParseOrSemanticError constr_from_ptr(long ptr) {
25 bindings.LDKParseOrSemanticError raw_val = bindings.LDKParseOrSemanticError_ref_from_ptr(ptr);
26 if (raw_val.getClass() == bindings.LDKParseOrSemanticError.ParseError.class) {
27 return new ParseError(ptr, (bindings.LDKParseOrSemanticError.ParseError)raw_val);
29 if (raw_val.getClass() == bindings.LDKParseOrSemanticError.SemanticError.class) {
30 return new SemanticError(ptr, (bindings.LDKParseOrSemanticError.SemanticError)raw_val);
32 assert false; return null; // Unreachable without extending the (internal) bindings interface
36 * The invoice couldn't be decoded
38 public final static class ParseError extends ParseOrSemanticError {
39 public final org.ldk.structs.ParseError parse_error;
40 private ParseError(long ptr, bindings.LDKParseOrSemanticError.ParseError obj) {
42 long parse_error = obj.parse_error;
43 org.ldk.structs.ParseError parse_error_hu_conv = org.ldk.structs.ParseError.constr_from_ptr(parse_error);
44 parse_error_hu_conv.ptrs_to.add(this);
45 this.parse_error = parse_error_hu_conv;
49 * The invoice could be decoded but violates the BOLT11 standard
51 public final static class SemanticError extends ParseOrSemanticError {
52 public final org.ldk.enums.SemanticError semantic_error;
53 private SemanticError(long ptr, bindings.LDKParseOrSemanticError.SemanticError obj) {
55 this.semantic_error = obj.semantic_error;
59 long ret = bindings.ParseOrSemanticError_clone_ptr(this.ptr);
60 Reference.reachabilityFence(this);
65 * Creates a copy of the ParseOrSemanticError
67 public ParseOrSemanticError clone() {
68 long ret = bindings.ParseOrSemanticError_clone(this.ptr);
69 Reference.reachabilityFence(this);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.ParseOrSemanticError ret_hu_conv = org.ldk.structs.ParseOrSemanticError.constr_from_ptr(ret);
72 ret_hu_conv.ptrs_to.add(this);
77 * Utility method to constructs a new ParseError-variant ParseOrSemanticError
79 public static ParseOrSemanticError parse_error(ParseError a) {
80 long ret = bindings.ParseOrSemanticError_parse_error(a.ptr);
81 Reference.reachabilityFence(a);
82 if (ret >= 0 && ret <= 4096) { return null; }
83 org.ldk.structs.ParseOrSemanticError ret_hu_conv = org.ldk.structs.ParseOrSemanticError.constr_from_ptr(ret);
84 ret_hu_conv.ptrs_to.add(ret_hu_conv);
89 * Utility method to constructs a new SemanticError-variant ParseOrSemanticError
91 public static ParseOrSemanticError semantic_error(org.ldk.enums.SemanticError a) {
92 long ret = bindings.ParseOrSemanticError_semantic_error(a);
93 Reference.reachabilityFence(a);
94 if (ret >= 0 && ret <= 4096) { return null; }
95 org.ldk.structs.ParseOrSemanticError ret_hu_conv = org.ldk.structs.ParseOrSemanticError.constr_from_ptr(ret);
96 ret_hu_conv.ptrs_to.add(ret_hu_conv);
101 * Get the string representation of a ParseOrSemanticError object
103 public String to_str() {
104 String ret = bindings.ParseOrSemanticError_to_str(this.ptr);
105 Reference.reachabilityFence(this);