]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/PaymentSendFailure.ts
Merge pull request #14 from TheBlueMatt/2021-03-fix-enums
[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 partial_failure: Result_NoneAPIErrorZ[];
70         private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.PartialFailure) {
71                 super(null, ptr);
72                 const partial_failure: number[] = obj.partial_failure;
73                 Result_NoneAPIErrorZ[] partial_failure_conv_22_arr = new Result_NoneAPIErrorZ[partial_failure.length];
74                         for (int w = 0; w < partial_failure.length; w++) {
75                                 number partial_failure_conv_22 = partial_failure[w];
76                                 Result_NoneAPIErrorZ partial_failure_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(partial_failure_conv_22);
77                                 partial_failure_conv_22_arr[w] = partial_failure_conv_22_hu_conv;
78                         }
79                 this.partial_failure = partial_failure_conv_22_arr;
80         }
81 }
82         public PaymentSendFailure clone() {
83                 number ret = bindings.PaymentSendFailure_clone(this.ptr);
84                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
85                 ret_hu_conv.ptrs_to.add(this);
86                 return ret_hu_conv;
87         }
88
89 }