]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/Route.ts
Merge pull request #47 from TheBlueMatt/main
[ldk-java] / ts / structs / Route.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export default class Route extends CommonBase {
9                 constructor(_dummy: object, ptr: number) {
10                     super(ptr);
11                 }
12
13                 
14                 protected finalize() {
15                     super.finalize();
16
17                     if (this.ptr != 0) {
18                         bindings.Route_free(this.ptr);
19                     }
20                 }
21         public RouteHop[][] get_paths() {
22                 number[][] ret = bindings.Route_get_paths(this.ptr);
23                 RouteHop[][] ret_conv_12_arr = new RouteHop[ret.length][];
24                 for (int m = 0; m < ret.length; m++) {
25                         number[] ret_conv_12 = ret[m];
26                         RouteHop[] ret_conv_12_conv_10_arr = new RouteHop[ret_conv_12.length];
27                         for (int k = 0; k < ret_conv_12.length; k++) {
28                                 number ret_conv_12_conv_10 = ret_conv_12[k];
29                                 const ret_conv_12_conv_10_hu_conv: RouteHop = new RouteHop(null, ret_conv_12_conv_10);
30                                 ret_conv_12_conv_10_hu_conv.ptrs_to.add(this);
31                                 ret_conv_12_conv_10_arr[k] = ret_conv_12_conv_10_hu_conv;
32                         }
33                         ret_conv_12_arr[m] = ret_conv_12_conv_10_arr;
34                 }
35                 return ret_conv_12_arr;
36         }
37
38         public void set_paths(RouteHop[][] val) {
39                 bindings.Route_set_paths(this.ptr, val != null ? Arrays.stream(val).map(val_conv_12 -> val_conv_12 != null ? Arrays.stream(val_conv_12).map(val_conv_12_conv_10 -> val_conv_12_conv_10 == null ? 0 : val_conv_12_conv_10.ptr & ~1).toArray(number[]::new) : null).toArray(number[][]::new) : null);
40         }
41
42         public static Route constructor_new(RouteHop[][] paths_arg) {
43                 number ret = bindings.Route_new(paths_arg != null ? Arrays.stream(paths_arg).map(paths_arg_conv_12 -> paths_arg_conv_12 != null ? Arrays.stream(paths_arg_conv_12).map(paths_arg_conv_12_conv_10 -> paths_arg_conv_12_conv_10 == null ? 0 : paths_arg_conv_12_conv_10.ptr & ~1).toArray(number[]::new) : null).toArray(number[][]::new) : null);
44                 const ret_hu_conv: Route = new Route(null, ret);
45                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
46                 return ret_hu_conv;
47         }
48
49         public Route clone() {
50                 number ret = bindings.Route_clone(this.ptr);
51                 const ret_hu_conv: Route = new Route(null, ret);
52                 ret_hu_conv.ptrs_to.add(this);
53                 return ret_hu_conv;
54         }
55
56         public number hash() {
57                 number ret = bindings.Route_hash(this.ptr);
58                 return ret;
59         }
60
61         public boolean eq(Route b) {
62                 boolean ret = bindings.Route_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
63                 this.ptrs_to.add(b);
64                 return ret;
65         }
66
67         public number get_total_fees() {
68                 number ret = bindings.Route_get_total_fees(this.ptr);
69                 return ret;
70         }
71
72         public number get_total_amount() {
73                 number ret = bindings.Route_get_total_amount(this.ptr);
74                 return ret;
75         }
76
77         public Uint8Array write() {
78                 Uint8Array ret = bindings.Route_write(this.ptr);
79                 return ret;
80         }
81
82         public static Result_RouteDecodeErrorZ constructor_read(Uint8Array ser) {
83                 number ret = bindings.Route_read(ser);
84                 Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);
85                 return ret_hu_conv;
86         }
87
88 }