[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PaymentSendFailure.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one
10  * of several states. This enum is returned as the Err() type describing which state the payment
11  * is in, see the description of individual enum states for more.
12  * 
13  * [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route
14  */
15 public class PaymentSendFailure : CommonBase {
16         protected PaymentSendFailure(object _dummy, long ptr) : base(ptr) { }
17         ~PaymentSendFailure() {
18                 if (ptr != 0) { bindings.PaymentSendFailure_free(ptr); }
19         }
20
21         internal static PaymentSendFailure constr_from_ptr(long ptr) {
22                 long raw_ty = bindings.LDKPaymentSendFailure_ty_from_ptr(ptr);
23                 switch (raw_ty) {
24                         case 0: return new PaymentSendFailure_ParameterError(ptr);
25                         case 1: return new PaymentSendFailure_PathParameterError(ptr);
26                         case 2: return new PaymentSendFailure_AllFailedResendSafe(ptr);
27                         case 3: return new PaymentSendFailure_DuplicatePayment(ptr);
28                         case 4: return new PaymentSendFailure_PartialFailure(ptr);
29                         default:
30                                 throw new ArgumentException("Impossible enum variant");
31                 }
32         }
33
34         /** A PaymentSendFailure of type ParameterError */
35         public class PaymentSendFailure_ParameterError : PaymentSendFailure {
36                 public APIError parameter_error;
37                 internal PaymentSendFailure_ParameterError(long ptr) : base(null, ptr) {
38                         long parameter_error = bindings.LDKPaymentSendFailure_ParameterError_get_parameter_error(ptr);
39                         org.ldk.structs.APIError parameter_error_hu_conv = org.ldk.structs.APIError.constr_from_ptr(parameter_error);
40                         if (parameter_error_hu_conv != null) { parameter_error_hu_conv.ptrs_to.AddLast(this); };
41                         this.parameter_error = parameter_error_hu_conv;
42                 }
43         }
44         /** A PaymentSendFailure of type PathParameterError */
45         public class PaymentSendFailure_PathParameterError : PaymentSendFailure {
46                 public Result_NoneAPIErrorZ[] path_parameter_error;
47                 internal PaymentSendFailure_PathParameterError(long ptr) : base(null, ptr) {
48                         long path_parameter_error = bindings.LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(ptr);
49                         int path_parameter_error_conv_22_len = InternalUtils.getArrayLength(path_parameter_error);
50                         Result_NoneAPIErrorZ[] path_parameter_error_conv_22_arr = new Result_NoneAPIErrorZ[path_parameter_error_conv_22_len];
51                         for (int w = 0; w < path_parameter_error_conv_22_len; w++) {
52                                 long path_parameter_error_conv_22 = InternalUtils.getU64ArrayElem(path_parameter_error, w);
53                                 Result_NoneAPIErrorZ path_parameter_error_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(path_parameter_error_conv_22);
54                                 path_parameter_error_conv_22_arr[w] = path_parameter_error_conv_22_hu_conv;
55                         }
56                         bindings.free_buffer(path_parameter_error);
57                         this.path_parameter_error = path_parameter_error_conv_22_arr;
58                 }
59         }
60         /** A PaymentSendFailure of type AllFailedResendSafe */
61         public class PaymentSendFailure_AllFailedResendSafe : PaymentSendFailure {
62                 public APIError[] all_failed_resend_safe;
63                 internal PaymentSendFailure_AllFailedResendSafe(long ptr) : base(null, ptr) {
64                         long all_failed_resend_safe = bindings.LDKPaymentSendFailure_AllFailedResendSafe_get_all_failed_resend_safe(ptr);
65                         int all_failed_resend_safe_conv_10_len = InternalUtils.getArrayLength(all_failed_resend_safe);
66                         APIError[] all_failed_resend_safe_conv_10_arr = new APIError[all_failed_resend_safe_conv_10_len];
67                         for (int k = 0; k < all_failed_resend_safe_conv_10_len; k++) {
68                                 long all_failed_resend_safe_conv_10 = InternalUtils.getU64ArrayElem(all_failed_resend_safe, k);
69                                 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);
70                                 if (all_failed_resend_safe_conv_10_hu_conv != null) { all_failed_resend_safe_conv_10_hu_conv.ptrs_to.AddLast(this); };
71                                 all_failed_resend_safe_conv_10_arr[k] = all_failed_resend_safe_conv_10_hu_conv;
72                         }
73                         bindings.free_buffer(all_failed_resend_safe);
74                         this.all_failed_resend_safe = all_failed_resend_safe_conv_10_arr;
75                 }
76         }
77         /** A PaymentSendFailure of type DuplicatePayment */
78         public class PaymentSendFailure_DuplicatePayment : PaymentSendFailure {
79                 internal PaymentSendFailure_DuplicatePayment(long ptr) : base(null, ptr) {
80                 }
81         }
82         /** A PaymentSendFailure of type PartialFailure */
83         public class PaymentSendFailure_PartialFailure : PaymentSendFailure {
84                 /**
85                  * The errors themselves, in the same order as the paths from the route.
86                  */
87                 public Result_NoneAPIErrorZ[] results;
88                 /**
89                  * If some paths failed without irrevocably committing to the new HTLC(s), this will
90                  * contain a [`RouteParameters`] object for the failing paths.
91                  * 
92                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
93                  */
94                 public RouteParameters failed_paths_retry;
95                 /**
96                  * The payment id for the payment, which is now at least partially pending.
97                  */
98                 public byte[] payment_id;
99                 internal PaymentSendFailure_PartialFailure(long ptr) : base(null, ptr) {
100                         long results = bindings.LDKPaymentSendFailure_PartialFailure_get_results(ptr);
101                         int results_conv_22_len = InternalUtils.getArrayLength(results);
102                         Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results_conv_22_len];
103                         for (int w = 0; w < results_conv_22_len; w++) {
104                                 long results_conv_22 = InternalUtils.getU64ArrayElem(results, w);
105                                 Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
106                                 results_conv_22_arr[w] = results_conv_22_hu_conv;
107                         }
108                         bindings.free_buffer(results);
109                         this.results = results_conv_22_arr;
110                         long failed_paths_retry = bindings.LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(ptr);
111                         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); }
112                         if (failed_paths_retry_hu_conv != null) { failed_paths_retry_hu_conv.ptrs_to.AddLast(this); };
113                         this.failed_paths_retry = failed_paths_retry_hu_conv;
114                         long payment_id = bindings.LDKPaymentSendFailure_PartialFailure_get_payment_id(ptr);
115                         byte[] payment_id_conv = InternalUtils.decodeUint8Array(payment_id);
116                         this.payment_id = payment_id_conv;
117                 }
118         }
119         internal long clone_ptr() {
120                 long ret = bindings.PaymentSendFailure_clone_ptr(this.ptr);
121                 GC.KeepAlive(this);
122                 return ret;
123         }
124
125         /**
126          * Creates a copy of the PaymentSendFailure
127          */
128         public PaymentSendFailure clone() {
129                 long ret = bindings.PaymentSendFailure_clone(this.ptr);
130                 GC.KeepAlive(this);
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
133                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
134                 return ret_hu_conv;
135         }
136
137         /**
138          * Utility method to constructs a new ParameterError-variant PaymentSendFailure
139          */
140         public static PaymentSendFailure parameter_error(org.ldk.structs.APIError a) {
141                 long ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
142                 GC.KeepAlive(a);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
146                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
147                 return ret_hu_conv;
148         }
149
150         /**
151          * Utility method to constructs a new PathParameterError-variant PaymentSendFailure
152          */
153         public static PaymentSendFailure path_parameter_error(Result_NoneAPIErrorZ[] a) {
154                 long ret = bindings.PaymentSendFailure_path_parameter_error(InternalUtils.encodeUint64Array(InternalUtils.mapArray(a, a_conv_22 => a_conv_22 != null ? a_conv_22.ptr : 0)));
155                 GC.KeepAlive(a);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
159                 return ret_hu_conv;
160         }
161
162         /**
163          * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure
164          */
165         public static PaymentSendFailure all_failed_resend_safe(APIError[] a) {
166                 long ret = bindings.PaymentSendFailure_all_failed_resend_safe(InternalUtils.encodeUint64Array(InternalUtils.mapArray(a, a_conv_10 => a_conv_10.ptr)));
167                 GC.KeepAlive(a);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
170                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
171                 foreach (APIError a_conv_10 in a) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a_conv_10); }; };
172                 return ret_hu_conv;
173         }
174
175         /**
176          * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure
177          */
178         public static PaymentSendFailure duplicate_payment() {
179                 long ret = bindings.PaymentSendFailure_duplicate_payment();
180                 if (ret >= 0 && ret <= 4096) { return null; }
181                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
182                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
183                 return ret_hu_conv;
184         }
185
186         /**
187          * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
188          */
189         public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] results, org.ldk.structs.RouteParameters failed_paths_retry, byte[] payment_id) {
190                 long ret = bindings.PaymentSendFailure_partial_failure(InternalUtils.encodeUint64Array(InternalUtils.mapArray(results, results_conv_22 => results_conv_22 != null ? results_conv_22.ptr : 0)), failed_paths_retry == null ? 0 : failed_paths_retry.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)));
191                 GC.KeepAlive(results);
192                 GC.KeepAlive(failed_paths_retry);
193                 GC.KeepAlive(payment_id);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
196                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
197                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(failed_paths_retry); };
198                 return ret_hu_conv;
199         }
200
201         /**
202          * Checks if two PaymentSendFailures contain equal inner contents.
203          * This ignores pointers and is_owned flags and looks at the values in fields.
204          */
205         public bool eq(org.ldk.structs.PaymentSendFailure b) {
206                 bool ret = bindings.PaymentSendFailure_eq(this.ptr, b == null ? 0 : b.ptr);
207                 GC.KeepAlive(this);
208                 GC.KeepAlive(b);
209                 return ret;
210         }
211
212         public override bool Equals(object o) {
213                 if (!(o is PaymentSendFailure)) return false;
214                 return this.eq((PaymentSendFailure)o);
215         }
216 }
217 } } }