6 namespace org { namespace ldk { namespace structs {
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.
13 * [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route
15 public class PaymentSendFailure : CommonBase {
16 protected PaymentSendFailure(object _dummy, long ptr) : base(ptr) { }
17 ~PaymentSendFailure() {
18 if (ptr != 0) { bindings.PaymentSendFailure_free(ptr); }
21 internal static PaymentSendFailure constr_from_ptr(long ptr) {
22 long raw_ty = bindings.LDKPaymentSendFailure_ty_from_ptr(ptr);
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);
30 throw new ArgumentException("Impossible enum variant");
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;
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 = path_parameter_error.Length;
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 = 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;
56 this.path_parameter_error = path_parameter_error_conv_22_arr;
59 /** A PaymentSendFailure of type AllFailedResendSafe */
60 public class PaymentSendFailure_AllFailedResendSafe : PaymentSendFailure {
61 public APIError[] all_failed_resend_safe;
62 internal PaymentSendFailure_AllFailedResendSafe(long ptr) : base(null, ptr) {
63 long[] all_failed_resend_safe = bindings.LDKPaymentSendFailure_AllFailedResendSafe_get_all_failed_resend_safe(ptr);
64 int all_failed_resend_safe_conv_10_len = all_failed_resend_safe.Length;
65 APIError[] all_failed_resend_safe_conv_10_arr = new APIError[all_failed_resend_safe_conv_10_len];
66 for (int k = 0; k < all_failed_resend_safe_conv_10_len; k++) {
67 long all_failed_resend_safe_conv_10 = all_failed_resend_safe[k];
68 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);
69 if (all_failed_resend_safe_conv_10_hu_conv != null) { all_failed_resend_safe_conv_10_hu_conv.ptrs_to.AddLast(this); };
70 all_failed_resend_safe_conv_10_arr[k] = all_failed_resend_safe_conv_10_hu_conv;
72 this.all_failed_resend_safe = all_failed_resend_safe_conv_10_arr;
75 /** A PaymentSendFailure of type DuplicatePayment */
76 public class PaymentSendFailure_DuplicatePayment : PaymentSendFailure {
77 internal PaymentSendFailure_DuplicatePayment(long ptr) : base(null, ptr) {
80 /** A PaymentSendFailure of type PartialFailure */
81 public class PaymentSendFailure_PartialFailure : PaymentSendFailure {
83 * The errors themselves, in the same order as the paths from the route.
85 public Result_NoneAPIErrorZ[] results;
87 * If some paths failed without irrevocably committing to the new HTLC(s), this will
88 * contain a [`RouteParameters`] object for the failing paths.
90 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
92 public RouteParameters failed_paths_retry;
94 * The payment id for the payment, which is now at least partially pending.
96 public byte[] payment_id;
97 internal PaymentSendFailure_PartialFailure(long ptr) : base(null, ptr) {
98 long[] results = bindings.LDKPaymentSendFailure_PartialFailure_get_results(ptr);
99 int results_conv_22_len = results.Length;
100 Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results_conv_22_len];
101 for (int w = 0; w < results_conv_22_len; w++) {
102 long results_conv_22 = results[w];
103 Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
104 results_conv_22_arr[w] = results_conv_22_hu_conv;
106 this.results = results_conv_22_arr;
107 long failed_paths_retry = bindings.LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(ptr);
108 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); }
109 if (failed_paths_retry_hu_conv != null) { failed_paths_retry_hu_conv.ptrs_to.AddLast(this); };
110 this.failed_paths_retry = failed_paths_retry_hu_conv;
111 this.payment_id = bindings.LDKPaymentSendFailure_PartialFailure_get_payment_id(ptr);
114 internal long clone_ptr() {
115 long ret = bindings.PaymentSendFailure_clone_ptr(this.ptr);
121 * Creates a copy of the PaymentSendFailure
123 public PaymentSendFailure clone() {
124 long ret = bindings.PaymentSendFailure_clone(this.ptr);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
133 * Utility method to constructs a new ParameterError-variant PaymentSendFailure
135 public static PaymentSendFailure parameter_error(org.ldk.structs.APIError a) {
136 long ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
138 if (ret >= 0 && ret <= 4096) { return null; }
139 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
140 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
141 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
146 * Utility method to constructs a new PathParameterError-variant PaymentSendFailure
148 public static PaymentSendFailure path_parameter_error(Result_NoneAPIErrorZ[] a) {
149 long ret = bindings.PaymentSendFailure_path_parameter_error(a != null ? InternalUtils.mapArray(a, a_conv_22 => a_conv_22 != null ? a_conv_22.ptr : 0) : null);
151 if (ret >= 0 && ret <= 4096) { return null; }
152 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
153 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
158 * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure
160 public static PaymentSendFailure all_failed_resend_safe(APIError[] a) {
161 long ret = bindings.PaymentSendFailure_all_failed_resend_safe(a != null ? InternalUtils.mapArray(a, a_conv_10 => a_conv_10.ptr) : null);
163 if (ret >= 0 && ret <= 4096) { return null; }
164 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
165 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
166 foreach (APIError a_conv_10 in a) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a_conv_10); }; };
171 * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure
173 public static PaymentSendFailure duplicate_payment() {
174 long ret = bindings.PaymentSendFailure_duplicate_payment();
175 if (ret >= 0 && ret <= 4096) { return null; }
176 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
177 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
182 * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
184 public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] results, org.ldk.structs.RouteParameters failed_paths_retry, byte[] payment_id) {
185 long ret = bindings.PaymentSendFailure_partial_failure(results != null ? InternalUtils.mapArray(results, results_conv_22 => results_conv_22 != null ? results_conv_22.ptr : 0) : null, failed_paths_retry == null ? 0 : failed_paths_retry.ptr, InternalUtils.check_arr_len(payment_id, 32));
186 GC.KeepAlive(results);
187 GC.KeepAlive(failed_paths_retry);
188 GC.KeepAlive(payment_id);
189 if (ret >= 0 && ret <= 4096) { return null; }
190 org.ldk.structs.PaymentSendFailure ret_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(ret);
191 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
192 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(failed_paths_retry); };