1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Indicates an error on the client's part (usually some variant of attempting to use too-low or
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class APIError extends CommonBase {
16 private APIError(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.APIError_free(ptr); }
22 static APIError constr_from_ptr(long ptr) {
23 bindings.LDKAPIError raw_val = bindings.LDKAPIError_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKAPIError.APIMisuseError.class) {
25 return new APIMisuseError(ptr, (bindings.LDKAPIError.APIMisuseError)raw_val);
27 if (raw_val.getClass() == bindings.LDKAPIError.FeeRateTooHigh.class) {
28 return new FeeRateTooHigh(ptr, (bindings.LDKAPIError.FeeRateTooHigh)raw_val);
30 if (raw_val.getClass() == bindings.LDKAPIError.RouteError.class) {
31 return new RouteError(ptr, (bindings.LDKAPIError.RouteError)raw_val);
33 if (raw_val.getClass() == bindings.LDKAPIError.ChannelUnavailable.class) {
34 return new ChannelUnavailable(ptr, (bindings.LDKAPIError.ChannelUnavailable)raw_val);
36 if (raw_val.getClass() == bindings.LDKAPIError.MonitorUpdateFailed.class) {
37 return new MonitorUpdateFailed(ptr, (bindings.LDKAPIError.MonitorUpdateFailed)raw_val);
39 assert false; return null; // Unreachable without extending the (internal) bindings interface
42 public final static class APIMisuseError extends APIError {
44 * A human-readable error message
46 public final String err;
47 private APIMisuseError(long ptr, bindings.LDKAPIError.APIMisuseError obj) {
52 public final static class FeeRateTooHigh extends APIError {
54 * A human-readable error message
56 public final String err;
58 * The feerate which was too high.
60 public final int feerate;
61 private FeeRateTooHigh(long ptr, bindings.LDKAPIError.FeeRateTooHigh obj) {
64 this.feerate = obj.feerate;
67 public final static class RouteError extends APIError {
69 * A human-readable error message
71 public final String err;
72 private RouteError(long ptr, bindings.LDKAPIError.RouteError obj) {
77 public final static class ChannelUnavailable extends APIError {
79 * A human-readable error message
81 public final String err;
82 private ChannelUnavailable(long ptr, bindings.LDKAPIError.ChannelUnavailable obj) {
87 public final static class MonitorUpdateFailed extends APIError {
88 private MonitorUpdateFailed(long ptr, bindings.LDKAPIError.MonitorUpdateFailed obj) {
93 * Creates a copy of the APIError
95 public APIError clone() {
96 long ret = bindings.APIError_clone(this.ptr);
97 if (ret < 1024) { return null; }
98 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
99 ret_hu_conv.ptrs_to.add(this);
104 * Utility method to constructs a new APIMisuseError-variant APIError
106 public static APIError apimisuse_error(java.lang.String err) {
107 long ret = bindings.APIError_apimisuse_error(err);
108 if (ret < 1024) { return null; }
109 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
110 ret_hu_conv.ptrs_to.add(ret_hu_conv);
115 * Utility method to constructs a new FeeRateTooHigh-variant APIError
117 public static APIError fee_rate_too_high(java.lang.String err, int feerate) {
118 long ret = bindings.APIError_fee_rate_too_high(err, feerate);
119 if (ret < 1024) { return null; }
120 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
121 ret_hu_conv.ptrs_to.add(ret_hu_conv);
126 * Utility method to constructs a new RouteError-variant APIError
128 public static APIError route_error(java.lang.String err) {
129 long ret = bindings.APIError_route_error(err);
130 if (ret < 1024) { return null; }
131 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
132 ret_hu_conv.ptrs_to.add(ret_hu_conv);
137 * Utility method to constructs a new ChannelUnavailable-variant APIError
139 public static APIError channel_unavailable(java.lang.String err) {
140 long ret = bindings.APIError_channel_unavailable(err);
141 if (ret < 1024) { return null; }
142 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
143 ret_hu_conv.ptrs_to.add(ret_hu_conv);
148 * Utility method to constructs a new MonitorUpdateFailed-variant APIError
150 public static APIError monitor_update_failed() {
151 long ret = bindings.APIError_monitor_update_failed();
152 if (ret < 1024) { return null; }
153 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
154 ret_hu_conv.ptrs_to.add(ret_hu_conv);