2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class PaymentSendFailure extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.PaymentSendFailure_free(this.ptr); }
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);
16 if (raw_val instanceof bindings.LDKPaymentSendFailure.PathParameterError) {
17 return new PathParameterError(this.ptr, raw_val);
19 if (raw_val instanceof bindings.LDKPaymentSendFailure.AllFailedRetrySafe) {
20 return new AllFailedRetrySafe(this.ptr, raw_val);
22 if (raw_val instanceof bindings.LDKPaymentSendFailure.PartialFailure) {
23 return new PartialFailure(this.ptr, raw_val);
25 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
29 export class ParameterError extends PaymentSendFailure {
30 public parameter_error: APIError;
31 private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.ParameterError) {
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;
39 export class PathParameterError extends PaymentSendFailure {
40 public path_parameter_error: Result_NoneAPIErrorZ[];
41 private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.PathParameterError) {
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;
50 this.path_parameter_error = path_parameter_error_conv_22_arr;
53 export class AllFailedRetrySafe extends PaymentSendFailure {
54 public all_failed_retry_safe: APIError[];
55 private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.AllFailedRetrySafe) {
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;
65 this.all_failed_retry_safe = all_failed_retry_safe_conv_10_arr;
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) {
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;
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;
89 public number clone_ptr() {
90 number ret = bindings.PaymentSendFailure_clone_ptr(this.ptr);
94 public PaymentSendFailure clone() {
95 number ret = bindings.PaymentSendFailure_clone(this.ptr);
96 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
97 ret_hu_conv.ptrs_to.add(this);
101 public static PaymentSendFailure constructor_parameter_error(APIError a) {
102 number ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
103 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
104 ret_hu_conv.ptrs_to.add(ret_hu_conv);
108 public static PaymentSendFailure constructor_path_parameter_error(Result_NoneAPIErrorZ[] a) {
109 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);
110 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
111 ret_hu_conv.ptrs_to.add(ret_hu_conv);
115 public static PaymentSendFailure constructor_all_failed_retry_safe(APIError[] a) {
116 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);
117 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
118 ret_hu_conv.ptrs_to.add(ret_hu_conv);
122 public static PaymentSendFailure constructor_partial_failure(Result_NoneAPIErrorZ[] results, RouteParameters failed_paths_retry, Uint8Array payment_id) {
123 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, InternalUtils.check_arr_len(payment_id, 32));
124 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
125 ret_hu_conv.ptrs_to.add(ret_hu_conv);