[Java] Update auto-generated Java bindings to LDK 0.0.121
[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.BlindedPathAdvanceFailed.class) {
51                         return new BlindedPathAdvanceFailed(ptr, (bindings.LDKSendError.BlindedPathAdvanceFailed)raw_val);
52                 }
53                 assert false; return null; // Unreachable without extending the (internal) bindings interface
54         }
55
56         /**
57          * Errored computing onion message packet keys.
58          */
59         public final static class Secp256k1 extends SendError {
60                 public final org.ldk.enums.Secp256k1Error secp256k1;
61                 private Secp256k1(long ptr, bindings.LDKSendError.Secp256k1 obj) {
62                         super(null, ptr);
63                         this.secp256k1 = obj.secp256k1;
64                 }
65         }
66         /**
67          * Because implementations such as Eclair will drop onion messages where the message packet
68          * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size.
69          */
70         public final static class TooBigPacket extends SendError {
71                 private TooBigPacket(long ptr, bindings.LDKSendError.TooBigPacket obj) {
72                         super(null, ptr);
73                 }
74         }
75         /**
76          * The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded
77          * hops.
78          */
79         public final static class TooFewBlindedHops extends SendError {
80                 private TooFewBlindedHops(long ptr, bindings.LDKSendError.TooFewBlindedHops obj) {
81                         super(null, ptr);
82                 }
83         }
84         /**
85          * The first hop is not a peer and doesn't have a known [`SocketAddress`].
86          */
87         public final static class InvalidFirstHop extends SendError {
88                 public final byte[] invalid_first_hop;
89                 private InvalidFirstHop(long ptr, bindings.LDKSendError.InvalidFirstHop obj) {
90                         super(null, ptr);
91                         this.invalid_first_hop = obj.invalid_first_hop;
92                 }
93         }
94         /**
95          * A path from the sender to the destination could not be found by the [`MessageRouter`].
96          */
97         public final static class PathNotFound extends SendError {
98                 private PathNotFound(long ptr, bindings.LDKSendError.PathNotFound obj) {
99                         super(null, ptr);
100                 }
101         }
102         /**
103          * Onion message contents must have a TLV type >= 64.
104          */
105         public final static class InvalidMessage extends SendError {
106                 private InvalidMessage(long ptr, bindings.LDKSendError.InvalidMessage obj) {
107                         super(null, ptr);
108                 }
109         }
110         /**
111          * Our next-hop peer's buffer was full or our total outbound buffer was full.
112          */
113         public final static class BufferFull extends SendError {
114                 private BufferFull(long ptr, bindings.LDKSendError.BufferFull obj) {
115                         super(null, ptr);
116                 }
117         }
118         /**
119          * Failed to retrieve our node id from the provided [`NodeSigner`].
120          * 
121          * [`NodeSigner`]: crate::sign::NodeSigner
122          */
123         public final static class GetNodeIdFailed extends SendError {
124                 private GetNodeIdFailed(long ptr, bindings.LDKSendError.GetNodeIdFailed obj) {
125                         super(null, ptr);
126                 }
127         }
128         /**
129          * We attempted to send to a blinded path where we are the introduction node, and failed to
130          * advance the blinded path to make the second hop the new introduction node. Either
131          * [`NodeSigner::ecdh`] failed, we failed to tweak the current blinding point to get the
132          * new blinding point, or we were attempting to send to ourselves.
133          */
134         public final static class BlindedPathAdvanceFailed extends SendError {
135                 private BlindedPathAdvanceFailed(long ptr, bindings.LDKSendError.BlindedPathAdvanceFailed obj) {
136                         super(null, ptr);
137                 }
138         }
139         long clone_ptr() {
140                 long ret = bindings.SendError_clone_ptr(this.ptr);
141                 Reference.reachabilityFence(this);
142                 return ret;
143         }
144
145         /**
146          * Creates a copy of the SendError
147          */
148         public SendError clone() {
149                 long ret = bindings.SendError_clone(this.ptr);
150                 Reference.reachabilityFence(this);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
153                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Utility method to constructs a new Secp256k1-variant SendError
159          */
160         public static SendError secp256k1(org.ldk.enums.Secp256k1Error a) {
161                 long ret = bindings.SendError_secp256k1(a);
162                 Reference.reachabilityFence(a);
163                 if (ret >= 0 && ret <= 4096) { return null; }
164                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
165                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
166                 return ret_hu_conv;
167         }
168
169         /**
170          * Utility method to constructs a new TooBigPacket-variant SendError
171          */
172         public static SendError too_big_packet() {
173                 long ret = bindings.SendError_too_big_packet();
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
176                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Utility method to constructs a new TooFewBlindedHops-variant SendError
182          */
183         public static SendError too_few_blinded_hops() {
184                 long ret = bindings.SendError_too_few_blinded_hops();
185                 if (ret >= 0 && ret <= 4096) { return null; }
186                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
187                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
188                 return ret_hu_conv;
189         }
190
191         /**
192          * Utility method to constructs a new InvalidFirstHop-variant SendError
193          */
194         public static SendError invalid_first_hop(byte[] a) {
195                 long ret = bindings.SendError_invalid_first_hop(InternalUtils.check_arr_len(a, 33));
196                 Reference.reachabilityFence(a);
197                 if (ret >= 0 && ret <= 4096) { return null; }
198                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
199                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
200                 return ret_hu_conv;
201         }
202
203         /**
204          * Utility method to constructs a new PathNotFound-variant SendError
205          */
206         public static SendError path_not_found() {
207                 long ret = bindings.SendError_path_not_found();
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.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 InvalidMessage-variant SendError
216          */
217         public static SendError invalid_message() {
218                 long ret = bindings.SendError_invalid_message();
219                 if (ret >= 0 && ret <= 4096) { return null; }
220                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.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 BufferFull-variant SendError
227          */
228         public static SendError buffer_full() {
229                 long ret = bindings.SendError_buffer_full();
230                 if (ret >= 0 && ret <= 4096) { return null; }
231                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
232                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
233                 return ret_hu_conv;
234         }
235
236         /**
237          * Utility method to constructs a new GetNodeIdFailed-variant SendError
238          */
239         public static SendError get_node_id_failed() {
240                 long ret = bindings.SendError_get_node_id_failed();
241                 if (ret >= 0 && ret <= 4096) { return null; }
242                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
243                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
244                 return ret_hu_conv;
245         }
246
247         /**
248          * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError
249          */
250         public static SendError blinded_path_advance_failed() {
251                 long ret = bindings.SendError_blinded_path_advance_failed();
252                 if (ret >= 0 && ret <= 4096) { return null; }
253                 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
254                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
255                 return ret_hu_conv;
256         }
257
258         /**
259          * Checks if two SendErrors contain equal inner contents.
260          * This ignores pointers and is_owned flags and looks at the values in fields.
261          */
262         public boolean eq(org.ldk.structs.SendError b) {
263                 boolean ret = bindings.SendError_eq(this.ptr, b == null ? 0 : b.ptr);
264                 Reference.reachabilityFence(this);
265                 Reference.reachabilityFence(b);
266                 return ret;
267         }
268
269         @Override public boolean equals(Object o) {
270                 if (!(o instanceof SendError)) return false;
271                 return this.eq((SendError)o);
272         }
273 }