[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / APIError.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  * Indicates an error on the client's part (usually some variant of attempting to use too-low or
13  * too-high values)
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class APIError extends CommonBase {
17         private APIError(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.APIError_free(ptr); }
22         }
23         static APIError constr_from_ptr(long ptr) {
24                 bindings.LDKAPIError raw_val = bindings.LDKAPIError_ref_from_ptr(ptr);
25                 if (raw_val.getClass() == bindings.LDKAPIError.APIMisuseError.class) {
26                         return new APIMisuseError(ptr, (bindings.LDKAPIError.APIMisuseError)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKAPIError.FeeRateTooHigh.class) {
29                         return new FeeRateTooHigh(ptr, (bindings.LDKAPIError.FeeRateTooHigh)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKAPIError.RouteError.class) {
32                         return new RouteError(ptr, (bindings.LDKAPIError.RouteError)raw_val);
33                 }
34                 if (raw_val.getClass() == bindings.LDKAPIError.ChannelUnavailable.class) {
35                         return new ChannelUnavailable(ptr, (bindings.LDKAPIError.ChannelUnavailable)raw_val);
36                 }
37                 if (raw_val.getClass() == bindings.LDKAPIError.MonitorUpdateFailed.class) {
38                         return new MonitorUpdateFailed(ptr, (bindings.LDKAPIError.MonitorUpdateFailed)raw_val);
39                 }
40                 if (raw_val.getClass() == bindings.LDKAPIError.IncompatibleShutdownScript.class) {
41                         return new IncompatibleShutdownScript(ptr, (bindings.LDKAPIError.IncompatibleShutdownScript)raw_val);
42                 }
43                 assert false; return null; // Unreachable without extending the (internal) bindings interface
44         }
45
46         /**
47          * Indicates the API was wholly misused (see err for more). Cases where these can be returned
48          * are documented, but generally indicates some precondition of a function was violated.
49          */
50         public final static class APIMisuseError extends APIError {
51                 /**
52                  * A human-readable error message
53                 */
54                 public final java.lang.String err;
55                 private APIMisuseError(long ptr, bindings.LDKAPIError.APIMisuseError obj) {
56                         super(null, ptr);
57                         this.err = obj.err;
58                 }
59         }
60         /**
61          * Due to a high feerate, we were unable to complete the request.
62          * For example, this may be returned if the feerate implies we cannot open a channel at the
63          * requested value, but opening a larger channel would succeed.
64          */
65         public final static class FeeRateTooHigh extends APIError {
66                 /**
67                  * A human-readable error message
68                 */
69                 public final java.lang.String err;
70                 /**
71                  * The feerate which was too high.
72                 */
73                 public final int feerate;
74                 private FeeRateTooHigh(long ptr, bindings.LDKAPIError.FeeRateTooHigh obj) {
75                         super(null, ptr);
76                         this.err = obj.err;
77                         this.feerate = obj.feerate;
78                 }
79         }
80         /**
81          * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
82          * too-many-hops, etc).
83          */
84         public final static class RouteError extends APIError {
85                 /**
86                  * A human-readable error message
87                 */
88                 public final java.lang.String err;
89                 private RouteError(long ptr, bindings.LDKAPIError.RouteError obj) {
90                         super(null, ptr);
91                         this.err = obj.err;
92                 }
93         }
94         /**
95          * We were unable to complete the request as the Channel required to do so is unable to
96          * complete the request (or was not found). This can take many forms, including disconnected
97          * peer, channel at capacity, channel shutting down, etc.
98          */
99         public final static class ChannelUnavailable extends APIError {
100                 /**
101                  * A human-readable error message
102                 */
103                 public final java.lang.String err;
104                 private ChannelUnavailable(long ptr, bindings.LDKAPIError.ChannelUnavailable obj) {
105                         super(null, ptr);
106                         this.err = obj.err;
107                 }
108         }
109         /**
110          * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
111          * attempted action to fail.
112          */
113         public final static class MonitorUpdateFailed extends APIError {
114                 private MonitorUpdateFailed(long ptr, bindings.LDKAPIError.MonitorUpdateFailed obj) {
115                         super(null, ptr);
116                 }
117         }
118         /**
119          * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible
120          * with the channel counterparty as negotiated in [`InitFeatures`].
121          * 
122          * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open
123          * a channel or cooperatively close one with this peer (and will have to force-close instead).
124          * 
125          * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
126          * [`InitFeatures`]: crate::ln::features::InitFeatures
127          */
128         public final static class IncompatibleShutdownScript extends APIError {
129                 /**
130                  * The incompatible shutdown script.
131                 */
132                 public final org.ldk.structs.ShutdownScript script;
133                 private IncompatibleShutdownScript(long ptr, bindings.LDKAPIError.IncompatibleShutdownScript obj) {
134                         super(null, ptr);
135                         long script = obj.script;
136                         ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new ShutdownScript(null, script); }
137                         script_hu_conv.ptrs_to.add(this);
138                         this.script = script_hu_conv;
139                 }
140         }
141         long clone_ptr() {
142                 long ret = bindings.APIError_clone_ptr(this.ptr);
143                 Reference.reachabilityFence(this);
144                 return ret;
145         }
146
147         /**
148          * Creates a copy of the APIError
149          */
150         public APIError clone() {
151                 long ret = bindings.APIError_clone(this.ptr);
152                 Reference.reachabilityFence(this);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
155                 ret_hu_conv.ptrs_to.add(this);
156                 return ret_hu_conv;
157         }
158
159         /**
160          * Utility method to constructs a new APIMisuseError-variant APIError
161          */
162         public static APIError apimisuse_error(java.lang.String err) {
163                 long ret = bindings.APIError_apimisuse_error(err);
164                 Reference.reachabilityFence(err);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
167                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
168                 return ret_hu_conv;
169         }
170
171         /**
172          * Utility method to constructs a new FeeRateTooHigh-variant APIError
173          */
174         public static APIError fee_rate_too_high(java.lang.String err, int feerate) {
175                 long ret = bindings.APIError_fee_rate_too_high(err, feerate);
176                 Reference.reachabilityFence(err);
177                 Reference.reachabilityFence(feerate);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
180                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
181                 return ret_hu_conv;
182         }
183
184         /**
185          * Utility method to constructs a new RouteError-variant APIError
186          */
187         public static APIError route_error(java.lang.String err) {
188                 long ret = bindings.APIError_route_error(err);
189                 Reference.reachabilityFence(err);
190                 if (ret >= 0 && ret <= 4096) { return null; }
191                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
192                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
193                 return ret_hu_conv;
194         }
195
196         /**
197          * Utility method to constructs a new ChannelUnavailable-variant APIError
198          */
199         public static APIError channel_unavailable(java.lang.String err) {
200                 long ret = bindings.APIError_channel_unavailable(err);
201                 Reference.reachabilityFence(err);
202                 if (ret >= 0 && ret <= 4096) { return null; }
203                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
204                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
205                 return ret_hu_conv;
206         }
207
208         /**
209          * Utility method to constructs a new MonitorUpdateFailed-variant APIError
210          */
211         public static APIError monitor_update_failed() {
212                 long ret = bindings.APIError_monitor_update_failed();
213                 if (ret >= 0 && ret <= 4096) { return null; }
214                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
215                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
216                 return ret_hu_conv;
217         }
218
219         /**
220          * Utility method to constructs a new IncompatibleShutdownScript-variant APIError
221          */
222         public static APIError incompatible_shutdown_script(ShutdownScript script) {
223                 long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr & ~1);
224                 Reference.reachabilityFence(script);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
227                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
228                 return ret_hu_conv;
229         }
230
231 }