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 * All-encompassing standard error type that processing can return
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class GraphSyncError extends CommonBase {
16 private GraphSyncError(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.GraphSyncError_free(ptr); }
22 static GraphSyncError constr_from_ptr(long ptr) {
23 bindings.LDKGraphSyncError raw_val = bindings.LDKGraphSyncError_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKGraphSyncError.DecodeError.class) {
25 return new DecodeError(ptr, (bindings.LDKGraphSyncError.DecodeError)raw_val);
27 if (raw_val.getClass() == bindings.LDKGraphSyncError.LightningError.class) {
28 return new LightningError(ptr, (bindings.LDKGraphSyncError.LightningError)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
34 * Error trying to read the update data, typically due to an erroneous data length indication
35 * that is greater than the actual amount of data provided
37 public final static class DecodeError extends GraphSyncError {
38 public final org.ldk.structs.DecodeError decode_error;
39 private DecodeError(long ptr, bindings.LDKGraphSyncError.DecodeError obj) {
41 long decode_error = obj.decode_error;
42 org.ldk.structs.DecodeError decode_error_hu_conv = null; if (decode_error < 0 || decode_error > 4096) { decode_error_hu_conv = new org.ldk.structs.DecodeError(null, decode_error); }
43 decode_error_hu_conv.ptrs_to.add(this);
44 this.decode_error = decode_error_hu_conv;
48 * Error applying the patch to the network graph, usually the result of updates that are too
49 * old or missing prerequisite data to the application of updates out of order
51 public final static class LightningError extends GraphSyncError {
52 public final org.ldk.structs.LightningError lightning_error;
53 private LightningError(long ptr, bindings.LDKGraphSyncError.LightningError obj) {
55 long lightning_error = obj.lightning_error;
56 org.ldk.structs.LightningError lightning_error_hu_conv = null; if (lightning_error < 0 || lightning_error > 4096) { lightning_error_hu_conv = new org.ldk.structs.LightningError(null, lightning_error); }
57 lightning_error_hu_conv.ptrs_to.add(this);
58 this.lightning_error = lightning_error_hu_conv;
62 long ret = bindings.GraphSyncError_clone_ptr(this.ptr);
63 Reference.reachabilityFence(this);
68 * Creates a copy of the GraphSyncError
70 public GraphSyncError clone() {
71 long ret = bindings.GraphSyncError_clone(this.ptr);
72 Reference.reachabilityFence(this);
73 if (ret >= 0 && ret <= 4096) { return null; }
74 org.ldk.structs.GraphSyncError ret_hu_conv = org.ldk.structs.GraphSyncError.constr_from_ptr(ret);
75 ret_hu_conv.ptrs_to.add(this);
80 * Utility method to constructs a new DecodeError-variant GraphSyncError
82 public static GraphSyncError decode_error(DecodeError a) {
83 long ret = bindings.GraphSyncError_decode_error(a == null ? 0 : a.ptr & ~1);
84 Reference.reachabilityFence(a);
85 if (ret >= 0 && ret <= 4096) { return null; }
86 org.ldk.structs.GraphSyncError ret_hu_conv = org.ldk.structs.GraphSyncError.constr_from_ptr(ret);
87 ret_hu_conv.ptrs_to.add(ret_hu_conv);
92 * Utility method to constructs a new LightningError-variant GraphSyncError
94 public static GraphSyncError lightning_error(LightningError a) {
95 long ret = bindings.GraphSyncError_lightning_error(a == null ? 0 : a.ptr & ~1);
96 Reference.reachabilityFence(a);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 org.ldk.structs.GraphSyncError ret_hu_conv = org.ldk.structs.GraphSyncError.constr_from_ptr(ret);
99 ret_hu_conv.ptrs_to.add(ret_hu_conv);