Update auto-generated bindings to 0.0.103
[ldk-java] / ts / structs / PaymentSendFailure.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class PaymentSendFailure extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.PaymentSendFailure_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): PaymentSendFailure {
12                 const raw_val: bindings.LDKPaymentSendFailure = bindings.LDKPaymentSendFailure_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKPaymentSendFailure.ParameterError) {
14                         return new ParameterError(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKPaymentSendFailure.PathParameterError) {
17                         return new PathParameterError(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKPaymentSendFailure.AllFailedRetrySafe) {
20                         return new AllFailedRetrySafe(this.ptr, raw_val);
21                 }
22                 if (raw_val instanceof bindings.LDKPaymentSendFailure.PartialFailure) {
23                         return new PartialFailure(this.ptr, raw_val);
24                 }
25                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
26         }
27
28 }
29 export class ParameterError extends PaymentSendFailure {
30         public parameter_error: APIError;
31         private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.ParameterError) {
32                 super(null, ptr);
33                 const parameter_error: number = obj.parameter_error;
34                 APIError parameter_error_hu_conv = APIError.constr_from_ptr(parameter_error);
35                         parameter_error_hu_conv.ptrs_to.add(this);
36                 this.parameter_error = parameter_error_hu_conv;
37         }
38 }
39 export class PathParameterError extends PaymentSendFailure {
40         public path_parameter_error: Result_NoneAPIErrorZ[];
41         private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.PathParameterError) {
42                 super(null, ptr);
43                 const path_parameter_error: number[] = obj.path_parameter_error;
44                 Result_NoneAPIErrorZ[] path_parameter_error_conv_22_arr = new Result_NoneAPIErrorZ[path_parameter_error.length];
45                         for (int w = 0; w < path_parameter_error.length; w++) {
46                                 number path_parameter_error_conv_22 = path_parameter_error[w];
47                                 Result_NoneAPIErrorZ path_parameter_error_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(path_parameter_error_conv_22);
48                                 path_parameter_error_conv_22_arr[w] = path_parameter_error_conv_22_hu_conv;
49                         }
50                 this.path_parameter_error = path_parameter_error_conv_22_arr;
51         }
52 }
53 export class AllFailedRetrySafe extends PaymentSendFailure {
54         public all_failed_retry_safe: APIError[];
55         private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.AllFailedRetrySafe) {
56                 super(null, ptr);
57                 const all_failed_retry_safe: number[] = obj.all_failed_retry_safe;
58                 APIError[] all_failed_retry_safe_conv_10_arr = new APIError[all_failed_retry_safe.length];
59                         for (int k = 0; k < all_failed_retry_safe.length; k++) {
60                                 number all_failed_retry_safe_conv_10 = all_failed_retry_safe[k];
61                                 APIError all_failed_retry_safe_conv_10_hu_conv = APIError.constr_from_ptr(all_failed_retry_safe_conv_10);
62                                 all_failed_retry_safe_conv_10_hu_conv.ptrs_to.add(this);
63                                 all_failed_retry_safe_conv_10_arr[k] = all_failed_retry_safe_conv_10_hu_conv;
64                         }
65                 this.all_failed_retry_safe = all_failed_retry_safe_conv_10_arr;
66         }
67 }
68 export class PartialFailure extends PaymentSendFailure {
69         public results: Result_NoneAPIErrorZ[];
70         public failed_paths_retry: RouteParameters;
71         public payment_id: Uint8Array;
72         private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.PartialFailure) {
73                 super(null, ptr);
74                 const results: number[] = obj.results;
75                 Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results.length];
76                         for (int w = 0; w < results.length; w++) {
77                                 number results_conv_22 = results[w];
78                                 Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
79                                 results_conv_22_arr[w] = results_conv_22_hu_conv;
80                         }
81                 this.results = results_conv_22_arr;
82                 const failed_paths_retry: number = obj.failed_paths_retry;
83                 const failed_paths_retry_hu_conv: RouteParameters = new RouteParameters(null, failed_paths_retry);
84                         failed_paths_retry_hu_conv.ptrs_to.add(this);
85                 this.failed_paths_retry = failed_paths_retry_hu_conv;
86                 this.payment_id = obj.payment_id;
87         }
88 }
89         public PaymentSendFailure clone() {
90                 number ret = bindings.PaymentSendFailure_clone(this.ptr);
91                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
92                 ret_hu_conv.ptrs_to.add(this);
93                 return ret_hu_conv;
94         }
95
96         public static PaymentSendFailure constructor_parameter_error(APIError a) {
97                 number ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
98                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
99                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
100                 return ret_hu_conv;
101         }
102
103         public static PaymentSendFailure constructor_path_parameter_error(Result_NoneAPIErrorZ[] a) {
104                 number ret = bindings.PaymentSendFailure_path_parameter_error(a != null ? Arrays.stream(a).map(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray(number[]::new) : null);
105                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
106                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
107                 return ret_hu_conv;
108         }
109
110         public static PaymentSendFailure constructor_all_failed_retry_safe(APIError[] a) {
111                 number ret = bindings.PaymentSendFailure_all_failed_retry_safe(a != null ? Arrays.stream(a).map(a_conv_10 -> a_conv_10.ptr).toArray(number[]::new) : null);
112                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
113                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
114                 return ret_hu_conv;
115         }
116
117         public static PaymentSendFailure constructor_partial_failure(Result_NoneAPIErrorZ[] results, RouteParameters failed_paths_retry, Uint8Array payment_id) {
118                 number ret = bindings.PaymentSendFailure_partial_failure(results != null ? Arrays.stream(results).map(results_conv_22 -> results_conv_22 != null ? results_conv_22.ptr : 0).toArray(number[]::new) : null, failed_paths_retry == null ? 0 : failed_paths_retry.ptr & ~1, payment_id);
119                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
120                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
121                 return ret_hu_conv;
122         }
123
124 }