[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / main / java / org / ldk / structs / SendError.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  * Errors that may occur when [sending an onion message].
13  * 
14  * [sending an onion message]: OnionMessenger::send_onion_message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class SendError extends CommonBase {
18         private SendError(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.SendError_free(ptr); }
23         }
24         static SendError constr_from_ptr(long ptr) {
25                 bindings.LDKSendError raw_val = bindings.LDKSendError_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKSendError.Secp256k1.class) {
27                         return new Secp256k1(ptr, (bindings.LDKSendError.Secp256k1)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKSendError.TooBigPacket.class) {
30                         return new TooBigPacket(ptr, (bindings.LDKSendError.TooBigPacket)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKSendError.TooFewBlindedHops.class) {
33                         return new TooFewBlindedHops(ptr, (bindings.LDKSendError.TooFewBlindedHops)raw_val);
34                 }
35                 if (raw_val.getClass() == bindings.LDKSendError.InvalidFirstHop.class) {
36                         return new InvalidFirstHop(ptr, (bindings.LDKSendError.InvalidFirstHop)raw_val);
37                 }
38                 if (raw_val.getClass() == bindings.LDKSendError.PathNotFound.class) {
39                         return new PathNotFound(ptr, (bindings.LDKSendError.PathNotFound)raw_val);
40                 }
41                 if (raw_val.getClass() == bindings.LDKSendError.InvalidMessage.class) {
42                         return new InvalidMessage(ptr, (bindings.LDKSendError.InvalidMessage)raw_val);
43                 }
44                 if (raw_val.getClass() == bindings.LDKSendError.BufferFull.class) {
45                         return new BufferFull(ptr, (bindings.LDKSendError.BufferFull)raw_val);
46                 }
47                 if (raw_val.getClass() == bindings.LDKSendError.GetNodeIdFailed.class) {
48                         return new GetNodeIdFailed(ptr, (bindings.LDKSendError.GetNodeIdFailed)raw_val);
49                 }
50                 if (raw_val.getClass() == bindings.LDKSendError.UnresolvedIntroductionNode.class) {
51                         return new UnresolvedIntroductionNode(ptr, (bindings.LDKSendError.UnresolvedIntroductionNode)raw_val);
52                 }
53                 if (raw_val.getClass() == bindings.LDKSendError.BlindedPathAdvanceFailed.class) {
54                         return new BlindedPathAdvanceFailed(ptr, (bindings.LDKSendError.BlindedPathAdvanceFailed)raw_val);
55                 }
56                 assert false; return null; // Unreachable without extending the (internal) bindings interface
57         }
58
59         /**
60          * Errored computing onion message packet keys.
61          */
62         public final static class Secp256k1 extends SendError {
63                 public final org.ldk.enums.Secp256k1Error secp256k1;
64                 private Secp256k1(long ptr, bindings.LDKSendError.Secp256k1 obj) {
65                         super(null, ptr);
66                         this.secp256k1 = obj.secp256k1;
67                 }
68         }
69         /**
70          * Because implementations such as Eclair will drop onion messages where the message packet
71          * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size.
72          */
73         public final static class TooBigPacket extends SendError {
74                 private TooBigPacket(long ptr, bindings.LDKSendError.TooBigPacket obj) {
75                         super(null, ptr);
76                 }
77         }
78         /**
79          * The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded
80          * hops.
81          */
82         public final static class TooFewBlindedHops extends SendError {
83                 private TooFewBlindedHops(long ptr, bindings.LDKSendError.TooFewBlindedHops obj) {
84                         super(null, ptr);
85                 }
86         }
87         /**
88          * The first hop is not a peer and doesn't have a known [`SocketAddress`].
89          */
90         public final static class InvalidFirstHop extends SendError {
91                 public final byte[] invalid_first_hop;
92                 private InvalidFirstHop(long ptr, bindings.LDKSendError.InvalidFirstHop obj) {
93                         super(null, ptr);
94                         this.invalid_first_hop = obj.invalid_first_hop;
95                 }
96         }
97         /**
98          * A path from the sender to the destination could not be found by the [`MessageRouter`].
99          */
100         public final static class PathNotFound extends SendError {
101                 private PathNotFound(long ptr, bindings.LDKSendError.PathNotFound obj) {
102                         super(null, ptr);
103                 }
104         }
105         /**
106          * Onion message contents must have a TLV type >= 64.
107          */
108         public final static class InvalidMessage extends SendError {
109                 private InvalidMessage(long ptr, bindings.LDKSendError.InvalidMessage obj) {
110                         super(null, ptr);
111                 }
112         }
113         /**
114          * Our next-hop peer's buffer was full or our total outbound buffer was full.
115          */
116         public final static class BufferFull extends SendError {
117                 private BufferFull(long ptr, bindings.LDKSendError.BufferFull obj) {
118                         super(null, ptr);
119                 }
120         }
121         /**
122          * Failed to retrieve our node id from the provided [`NodeSigner`].
123          * 
124          * [`NodeSigner`]: crate::sign::NodeSigner
125          */
126         public final static class GetNodeIdFailed extends SendError {
127                 private GetNodeIdFailed(long ptr, bindings.LDKSendError.GetNodeIdFailed obj) {
128                         super(null, ptr);
129                 }
130         }
131         /**
132          * The provided [`Destination`] has a blinded path with an unresolved introduction node. An
133          * attempt to resolve it in the [`MessageRouter`] when finding an [`OnionMessagePath`] likely
134          * failed.
135          */
136         public final static class UnresolvedIntroductionNode extends SendError {
137                 private UnresolvedIntroductionNode(long ptr, bindings.LDKSendError.UnresolvedIntroductionNode obj) {
138                         super(null, ptr);
139                 }
140         }
141         /**
142          * We attempted to send to a blinded path where we are the introduction node, and failed to
143          * advance the blinded path to make the second hop the new introduction node. Either
144          * [`NodeSigner::ecdh`] failed, we failed to tweak the current blinding point to get the
145          * new blinding point, or we were attempting to send to ourselves.
146          */
147         public final static class BlindedPathAdvanceFailed extends SendError {
148                 private BlindedPathAdvanceFailed(long ptr, bindings.LDKSendError.BlindedPathAdvanceFailed obj) {
149                         super(null, ptr);
150                 }
151         }
152         long clone_ptr() {
153                 long ret = bindings.SendError_clone_ptr(this.ptr);
154                 Reference.reachabilityFence(this);
155                 return ret;
156         }
157
158         /**
159          * Creates a copy of the SendError
160          */
161         public SendError clone() {
162                 long ret = bindings.SendError_clone(this.ptr);
163                 Reference.reachabilityFence(this);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
166                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
167                 return ret_hu_conv;
168         }
169
170         /**
171          * Utility method to constructs a new Secp256k1-variant SendError
172          */
173         public static SendError secp256k1(org.ldk.enums.Secp256k1Error a) {
174                 long ret = bindings.SendError_secp256k1(a);
175                 Reference.reachabilityFence(a);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
178                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
179                 return ret_hu_conv;
180         }
181
182         /**
183          * Utility method to constructs a new TooBigPacket-variant SendError
184          */
185         public static SendError too_big_packet() {
186                 long ret = bindings.SendError_too_big_packet();
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
190                 return ret_hu_conv;
191         }
192
193         /**
194          * Utility method to constructs a new TooFewBlindedHops-variant SendError
195          */
196         public static SendError too_few_blinded_hops() {
197                 long ret = bindings.SendError_too_few_blinded_hops();
198                 if (ret >= 0 && ret <= 4096) { return null; }
199                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
200                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
201                 return ret_hu_conv;
202         }
203
204         /**
205          * Utility method to constructs a new InvalidFirstHop-variant SendError
206          */
207         public static SendError invalid_first_hop(byte[] a) {
208                 long ret = bindings.SendError_invalid_first_hop(InternalUtils.check_arr_len(a, 33));
209                 Reference.reachabilityFence(a);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Utility method to constructs a new PathNotFound-variant SendError
218          */
219         public static SendError path_not_found() {
220                 long ret = bindings.SendError_path_not_found();
221                 if (ret >= 0 && ret <= 4096) { return null; }
222                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
223                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
224                 return ret_hu_conv;
225         }
226
227         /**
228          * Utility method to constructs a new InvalidMessage-variant SendError
229          */
230         public static SendError invalid_message() {
231                 long ret = bindings.SendError_invalid_message();
232                 if (ret >= 0 && ret <= 4096) { return null; }
233                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
234                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
235                 return ret_hu_conv;
236         }
237
238         /**
239          * Utility method to constructs a new BufferFull-variant SendError
240          */
241         public static SendError buffer_full() {
242                 long ret = bindings.SendError_buffer_full();
243                 if (ret >= 0 && ret <= 4096) { return null; }
244                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
245                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
246                 return ret_hu_conv;
247         }
248
249         /**
250          * Utility method to constructs a new GetNodeIdFailed-variant SendError
251          */
252         public static SendError get_node_id_failed() {
253                 long ret = bindings.SendError_get_node_id_failed();
254                 if (ret >= 0 && ret <= 4096) { return null; }
255                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
256                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
257                 return ret_hu_conv;
258         }
259
260         /**
261          * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError
262          */
263         public static SendError unresolved_introduction_node() {
264                 long ret = bindings.SendError_unresolved_introduction_node();
265                 if (ret >= 0 && ret <= 4096) { return null; }
266                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
267                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
268                 return ret_hu_conv;
269         }
270
271         /**
272          * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError
273          */
274         public static SendError blinded_path_advance_failed() {
275                 long ret = bindings.SendError_blinded_path_advance_failed();
276                 if (ret >= 0 && ret <= 4096) { return null; }
277                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
278                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
279                 return ret_hu_conv;
280         }
281
282         /**
283          * Generates a non-cryptographic 64-bit hash of the SendError.
284          */
285         public long hash() {
286                 long ret = bindings.SendError_hash(this.ptr);
287                 Reference.reachabilityFence(this);
288                 return ret;
289         }
290
291         @Override public int hashCode() {
292                 return (int)this.hash();
293         }
294         /**
295          * Checks if two SendErrors contain equal inner contents.
296          * This ignores pointers and is_owned flags and looks at the values in fields.
297          */
298         public boolean eq(org.ldk.structs.SendError b) {
299                 boolean ret = bindings.SendError_eq(this.ptr, b.ptr);
300                 Reference.reachabilityFence(this);
301                 Reference.reachabilityFence(b);
302                 return ret;
303         }
304
305         @Override public boolean equals(Object o) {
306                 if (!(o instanceof SendError)) return false;
307                 return this.eq((SendError)o);
308         }
309 }