[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / PaymentSendFailure.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  * If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one
13  * of several states. This enum is returned as the Err() type describing which state the payment
14  * is in, see the description of individual enum states for more.
15  * 
16  * [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class PaymentSendFailure extends CommonBase {
20         private PaymentSendFailure(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.PaymentSendFailure_free(ptr); }
25         }
26         static PaymentSendFailure constr_from_ptr(long ptr) {
27                 bindings.LDKPaymentSendFailure raw_val = bindings.LDKPaymentSendFailure_ref_from_ptr(ptr);
28                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.ParameterError.class) {
29                         return new ParameterError(ptr, (bindings.LDKPaymentSendFailure.ParameterError)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.PathParameterError.class) {
32                         return new PathParameterError(ptr, (bindings.LDKPaymentSendFailure.PathParameterError)raw_val);
33                 }
34                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.AllFailedResendSafe.class) {
35                         return new AllFailedResendSafe(ptr, (bindings.LDKPaymentSendFailure.AllFailedResendSafe)raw_val);
36                 }
37                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.DuplicatePayment.class) {
38                         return new DuplicatePayment(ptr, (bindings.LDKPaymentSendFailure.DuplicatePayment)raw_val);
39                 }
40                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.PartialFailure.class) {
41                         return new PartialFailure(ptr, (bindings.LDKPaymentSendFailure.PartialFailure)raw_val);
42                 }
43                 assert false; return null; // Unreachable without extending the (internal) bindings interface
44         }
45
46         /**
47          * A parameter which was passed to send_payment was invalid, preventing us from attempting to
48          * send the payment at all.
49          * 
50          * You can freely resend the payment in full (with the parameter error fixed).
51          * 
52          * Because the payment failed outright, no payment tracking is done and no
53          * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated.
54          * 
55          * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
56          * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
57          */
58         public final static class ParameterError extends PaymentSendFailure {
59                 public final org.ldk.structs.APIError parameter_error;
60                 private ParameterError(long ptr, bindings.LDKPaymentSendFailure.ParameterError obj) {
61                         super(null, ptr);
62                         long parameter_error = obj.parameter_error;
63                         org.ldk.structs.APIError parameter_error_hu_conv = org.ldk.structs.APIError.constr_from_ptr(parameter_error);
64                         if (parameter_error_hu_conv != null) { parameter_error_hu_conv.ptrs_to.add(this); };
65                         this.parameter_error = parameter_error_hu_conv;
66                 }
67         }
68         /**
69          * A parameter in a single path which was passed to send_payment was invalid, preventing us
70          * from attempting to send the payment at all.
71          * 
72          * You can freely resend the payment in full (with the parameter error fixed).
73          * 
74          * Because the payment failed outright, no payment tracking is done and no
75          * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated.
76          * 
77          * The results here are ordered the same as the paths in the route object which was passed to
78          * send_payment.
79          * 
80          * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
81          * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
82          */
83         public final static class PathParameterError extends PaymentSendFailure {
84                 public final Result_NoneAPIErrorZ[] path_parameter_error;
85                 private PathParameterError(long ptr, bindings.LDKPaymentSendFailure.PathParameterError obj) {
86                         super(null, ptr);
87                         long[] path_parameter_error = obj.path_parameter_error;
88                         int path_parameter_error_conv_22_len = path_parameter_error.length;
89                         Result_NoneAPIErrorZ[] path_parameter_error_conv_22_arr = new Result_NoneAPIErrorZ[path_parameter_error_conv_22_len];
90                         for (int w = 0; w < path_parameter_error_conv_22_len; w++) {
91                                 long path_parameter_error_conv_22 = path_parameter_error[w];
92                                 Result_NoneAPIErrorZ path_parameter_error_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(path_parameter_error_conv_22);
93                                 path_parameter_error_conv_22_arr[w] = path_parameter_error_conv_22_hu_conv;
94                         }
95                         this.path_parameter_error = path_parameter_error_conv_22_arr;
96                 }
97         }
98         /**
99          * All paths which were attempted failed to send, with no channel state change taking place.
100          * You can freely resend the payment in full (though you probably want to do so over different
101          * paths than the ones selected).
102          * 
103          * Because the payment failed outright, no payment tracking is done and no
104          * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated.
105          * 
106          * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
107          * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
108          */
109         public final static class AllFailedResendSafe extends PaymentSendFailure {
110                 public final APIError[] all_failed_resend_safe;
111                 private AllFailedResendSafe(long ptr, bindings.LDKPaymentSendFailure.AllFailedResendSafe obj) {
112                         super(null, ptr);
113                         long[] all_failed_resend_safe = obj.all_failed_resend_safe;
114                         int all_failed_resend_safe_conv_10_len = all_failed_resend_safe.length;
115                         APIError[] all_failed_resend_safe_conv_10_arr = new APIError[all_failed_resend_safe_conv_10_len];
116                         for (int k = 0; k < all_failed_resend_safe_conv_10_len; k++) {
117                                 long all_failed_resend_safe_conv_10 = all_failed_resend_safe[k];
118                                 org.ldk.structs.APIError all_failed_resend_safe_conv_10_hu_conv = org.ldk.structs.APIError.constr_from_ptr(all_failed_resend_safe_conv_10);
119                                 if (all_failed_resend_safe_conv_10_hu_conv != null) { all_failed_resend_safe_conv_10_hu_conv.ptrs_to.add(this); };
120                                 all_failed_resend_safe_conv_10_arr[k] = all_failed_resend_safe_conv_10_hu_conv;
121                         }
122                         this.all_failed_resend_safe = all_failed_resend_safe_conv_10_arr;
123                 }
124         }
125         /**
126          * Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
127          * yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]).
128          * 
129          * [`PaymentId`]: crate::ln::channelmanager::PaymentId
130          * [`Event::PaymentSent`]: crate::events::Event::PaymentSent
131          * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
132          */
133         public final static class DuplicatePayment extends PaymentSendFailure {
134                 private DuplicatePayment(long ptr, bindings.LDKPaymentSendFailure.DuplicatePayment obj) {
135                         super(null, ptr);
136                 }
137         }
138         /**
139          * Some paths that were attempted failed to send, though some paths may have succeeded. At least
140          * some paths have irrevocably committed to the HTLC.
141          * 
142          * The results here are ordered the same as the paths in the route object that was passed to
143          * send_payment.
144          * 
145          * Any entries that contain `Err(APIError::MonitorUpdateInprogress)` will send once a
146          * [`MonitorEvent::Completed`] is provided for the next-hop channel with the latest update_id.
147          * 
148          * [`MonitorEvent::Completed`]: crate::chain::channelmonitor::MonitorEvent::Completed
149          */
150         public final static class PartialFailure extends PaymentSendFailure {
151                 /**
152                  * The errors themselves, in the same order as the paths from the route.
153                 */
154                 public final Result_NoneAPIErrorZ[] results;
155                 /**
156                  * If some paths failed without irrevocably committing to the new HTLC(s), this will
157                  * contain a [`RouteParameters`] object for the failing paths.
158                  * 
159                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
160                 */
161                 @Nullable public final org.ldk.structs.RouteParameters failed_paths_retry;
162                 /**
163                  * The payment id for the payment, which is now at least partially pending.
164                 */
165                 public final byte[] payment_id;
166                 private PartialFailure(long ptr, bindings.LDKPaymentSendFailure.PartialFailure obj) {
167                         super(null, ptr);
168                         long[] results = obj.results;
169                         int results_conv_22_len = results.length;
170                         Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results_conv_22_len];
171                         for (int w = 0; w < results_conv_22_len; w++) {
172                                 long results_conv_22 = results[w];
173                                 Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
174                                 results_conv_22_arr[w] = results_conv_22_hu_conv;
175                         }
176                         this.results = results_conv_22_arr;
177                         long failed_paths_retry = obj.failed_paths_retry;
178                         org.ldk.structs.RouteParameters failed_paths_retry_hu_conv = null; if (failed_paths_retry < 0 || failed_paths_retry > 4096) { failed_paths_retry_hu_conv = new org.ldk.structs.RouteParameters(null, failed_paths_retry); }
179                         if (failed_paths_retry_hu_conv != null) { failed_paths_retry_hu_conv.ptrs_to.add(this); };
180                         this.failed_paths_retry = failed_paths_retry_hu_conv;
181                         this.payment_id = obj.payment_id;
182                 }
183         }
184         long clone_ptr() {
185                 long ret = bindings.PaymentSendFailure_clone_ptr(this.ptr);
186                 Reference.reachabilityFence(this);
187                 return ret;
188         }
189
190         /**
191          * Creates a copy of the PaymentSendFailure
192          */
193         public PaymentSendFailure clone() {
194                 long ret = bindings.PaymentSendFailure_clone(this.ptr);
195                 Reference.reachabilityFence(this);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Utility method to constructs a new ParameterError-variant PaymentSendFailure
204          */
205         public static PaymentSendFailure parameter_error(org.ldk.structs.APIError a) {
206                 long ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
207                 Reference.reachabilityFence(a);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
212                 return ret_hu_conv;
213         }
214
215         /**
216          * Utility method to constructs a new PathParameterError-variant PaymentSendFailure
217          */
218         public static PaymentSendFailure path_parameter_error(Result_NoneAPIErrorZ[] a) {
219                 long ret = bindings.PaymentSendFailure_path_parameter_error(a != null ? Arrays.stream(a).mapToLong(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray() : null);
220                 Reference.reachabilityFence(a);
221                 if (ret >= 0 && ret <= 4096) { return null; }
222                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.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 AllFailedResendSafe-variant PaymentSendFailure
229          */
230         public static PaymentSendFailure all_failed_resend_safe(APIError[] a) {
231                 long ret = bindings.PaymentSendFailure_all_failed_resend_safe(a != null ? Arrays.stream(a).mapToLong(a_conv_10 -> a_conv_10.ptr).toArray() : null);
232                 Reference.reachabilityFence(a);
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
236                 for (APIError a_conv_10: a) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a_conv_10); }; };
237                 return ret_hu_conv;
238         }
239
240         /**
241          * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure
242          */
243         public static PaymentSendFailure duplicate_payment() {
244                 long ret = bindings.PaymentSendFailure_duplicate_payment();
245                 if (ret >= 0 && ret <= 4096) { return null; }
246                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
247                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
248                 return ret_hu_conv;
249         }
250
251         /**
252          * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
253          */
254         public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] results, org.ldk.structs.RouteParameters failed_paths_retry, byte[] payment_id) {
255                 long ret = bindings.PaymentSendFailure_partial_failure(results != null ? Arrays.stream(results).mapToLong(results_conv_22 -> results_conv_22 != null ? results_conv_22.ptr : 0).toArray() : null, failed_paths_retry == null ? 0 : failed_paths_retry.ptr, InternalUtils.check_arr_len(payment_id, 32));
256                 Reference.reachabilityFence(results);
257                 Reference.reachabilityFence(failed_paths_retry);
258                 Reference.reachabilityFence(payment_id);
259                 if (ret >= 0 && ret <= 4096) { return null; }
260                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
261                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
262                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(failed_paths_retry); };
263                 return ret_hu_conv;
264         }
265
266         /**
267          * Checks if two PaymentSendFailures contain equal inner contents.
268          * This ignores pointers and is_owned flags and looks at the values in fields.
269          */
270         public boolean eq(org.ldk.structs.PaymentSendFailure b) {
271                 boolean ret = bindings.PaymentSendFailure_eq(this.ptr, b == null ? 0 : b.ptr);
272                 Reference.reachabilityFence(this);
273                 Reference.reachabilityFence(b);
274                 return ret;
275         }
276
277         @Override public boolean equals(Object o) {
278                 if (!(o instanceof PaymentSendFailure)) return false;
279                 return this.eq((PaymentSendFailure)o);
280         }
281 }