Update CI references to 0.0.122
[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.InvalidRoute.class) {
32                         return new InvalidRoute(ptr, (bindings.LDKAPIError.InvalidRoute)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.MonitorUpdateInProgress.class) {
38                         return new MonitorUpdateInProgress(ptr, (bindings.LDKAPIError.MonitorUpdateInProgress)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 InvalidRoute extends APIError {
85                 /**
86                  * A human-readable error message
87                 */
88                 public final java.lang.String err;
89                 private InvalidRoute(long ptr, bindings.LDKAPIError.InvalidRoute 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 [`chain::Watch::watch_channel`]/[`chain::Watch::update_channel`]
111          * returned a [`ChannelMonitorUpdateStatus::InProgress`] indicating the persistence of a
112          * monitor update is awaiting async resolution. Once it resolves the attempted action should
113          * complete automatically.
114          * 
115          * [`chain::Watch::watch_channel`]: crate::chain::Watch::watch_channel
116          * [`chain::Watch::update_channel`]: crate::chain::Watch::update_channel
117          * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
118          */
119         public final static class MonitorUpdateInProgress extends APIError {
120                 private MonitorUpdateInProgress(long ptr, bindings.LDKAPIError.MonitorUpdateInProgress obj) {
121                         super(null, ptr);
122                 }
123         }
124         /**
125          * [`SignerProvider::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible
126          * with the channel counterparty as negotiated in [`InitFeatures`].
127          * 
128          * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open
129          * a channel or cooperatively close one with this peer (and will have to force-close instead).
130          * 
131          * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey
132          * [`InitFeatures`]: crate::ln::features::InitFeatures
133          */
134         public final static class IncompatibleShutdownScript extends APIError {
135                 /**
136                  * The incompatible shutdown script.
137                 */
138                 public final org.ldk.structs.ShutdownScript script;
139                 private IncompatibleShutdownScript(long ptr, bindings.LDKAPIError.IncompatibleShutdownScript obj) {
140                         super(null, ptr);
141                         long script = obj.script;
142                         org.ldk.structs.ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new org.ldk.structs.ShutdownScript(null, script); }
143                         if (script_hu_conv != null) { script_hu_conv.ptrs_to.add(this); };
144                         this.script = script_hu_conv;
145                 }
146         }
147         long clone_ptr() {
148                 long ret = bindings.APIError_clone_ptr(this.ptr);
149                 Reference.reachabilityFence(this);
150                 return ret;
151         }
152
153         /**
154          * Creates a copy of the APIError
155          */
156         public APIError clone() {
157                 long ret = bindings.APIError_clone(this.ptr);
158                 Reference.reachabilityFence(this);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
161                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
162                 return ret_hu_conv;
163         }
164
165         /**
166          * Utility method to constructs a new APIMisuseError-variant APIError
167          */
168         public static APIError apimisuse_error(java.lang.String err) {
169                 long ret = bindings.APIError_apimisuse_error(err);
170                 Reference.reachabilityFence(err);
171                 if (ret >= 0 && ret <= 4096) { return null; }
172                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
173                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
174                 return ret_hu_conv;
175         }
176
177         /**
178          * Utility method to constructs a new FeeRateTooHigh-variant APIError
179          */
180         public static APIError fee_rate_too_high(java.lang.String err, int feerate) {
181                 long ret = bindings.APIError_fee_rate_too_high(err, feerate);
182                 Reference.reachabilityFence(err);
183                 Reference.reachabilityFence(feerate);
184                 if (ret >= 0 && ret <= 4096) { return null; }
185                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
186                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
187                 return ret_hu_conv;
188         }
189
190         /**
191          * Utility method to constructs a new InvalidRoute-variant APIError
192          */
193         public static APIError invalid_route(java.lang.String err) {
194                 long ret = bindings.APIError_invalid_route(err);
195                 Reference.reachabilityFence(err);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Utility method to constructs a new ChannelUnavailable-variant APIError
204          */
205         public static APIError channel_unavailable(java.lang.String err) {
206                 long ret = bindings.APIError_channel_unavailable(err);
207                 Reference.reachabilityFence(err);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
211                 return ret_hu_conv;
212         }
213
214         /**
215          * Utility method to constructs a new MonitorUpdateInProgress-variant APIError
216          */
217         public static APIError monitor_update_in_progress() {
218                 long ret = bindings.APIError_monitor_update_in_progress();
219                 if (ret >= 0 && ret <= 4096) { return null; }
220                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
221                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
222                 return ret_hu_conv;
223         }
224
225         /**
226          * Utility method to constructs a new IncompatibleShutdownScript-variant APIError
227          */
228         public static APIError incompatible_shutdown_script(org.ldk.structs.ShutdownScript script) {
229                 long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr);
230                 Reference.reachabilityFence(script);
231                 if (ret >= 0 && ret <= 4096) { return null; }
232                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
233                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
234                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(script); };
235                 return ret_hu_conv;
236         }
237
238         /**
239          * Checks if two APIErrors contain equal inner contents.
240          * This ignores pointers and is_owned flags and looks at the values in fields.
241          */
242         public boolean eq(org.ldk.structs.APIError b) {
243                 boolean ret = bindings.APIError_eq(this.ptr, b == null ? 0 : b.ptr);
244                 Reference.reachabilityFence(this);
245                 Reference.reachabilityFence(b);
246                 return ret;
247         }
248
249         @Override public boolean equals(Object o) {
250                 if (!(o instanceof APIError)) return false;
251                 return this.eq((APIError)o);
252         }
253         /**
254          * Serialize the APIError object into a byte array which can be read by APIError_read
255          */
256         public byte[] write() {
257                 byte[] ret = bindings.APIError_write(this.ptr);
258                 Reference.reachabilityFence(this);
259                 return ret;
260         }
261
262 }