Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / Route.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8
9 /**
10  * A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
11  * it can take multiple paths. Each path is composed of one or more hops through the network.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Route extends CommonBase {
15         Route(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.Route_free(ptr); }
20         }
21
22         /**
23          * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
24          * last RouteHop in each path must be the same.
25          * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
26          * destination. Thus, this must always be at least length one. While the maximum length of any
27          * given path is variable, keeping the length of any path to less than 20 should currently
28          * ensure it is viable.
29          */
30         public void set_paths(RouteHop[][] val) {
31                 bindings.Route_set_paths(this.ptr, Arrays.stream(val).map(val_conv_12 -> Arrays.stream(val_conv_12).mapToLong(val_conv_12_conv_10 -> val_conv_12_conv_10 == null ? 0 : val_conv_12_conv_10.ptr & ~1).toArray()).toArray(long[][]::new));
32                 /* TODO 2 RouteHop[]  */;
33         }
34
35         /**
36          * Constructs a new Route given each field
37          */
38         public static Route of(RouteHop[][] paths_arg) {
39                 long ret = bindings.Route_new(Arrays.stream(paths_arg).map(paths_arg_conv_12 -> Arrays.stream(paths_arg_conv_12).mapToLong(paths_arg_conv_12_conv_10 -> paths_arg_conv_12_conv_10 == null ? 0 : paths_arg_conv_12_conv_10.ptr & ~1).toArray()).toArray(long[][]::new));
40                 Route ret_hu_conv = new Route(null, ret);
41                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
42                 /* TODO 2 RouteHop[]  */;
43                 return ret_hu_conv;
44         }
45
46         /**
47          * Creates a copy of the Route
48          */
49         public Route clone() {
50                 long ret = bindings.Route_clone(this.ptr);
51                 Route ret_hu_conv = new Route(null, ret);
52                 ret_hu_conv.ptrs_to.add(this);
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Serialize the Route object into a byte array which can be read by Route_read
58          */
59         public byte[] write() {
60                 byte[] ret = bindings.Route_write(this.ptr);
61                 return ret;
62         }
63
64         /**
65          * Read a Route from a byte array, created by Route_write
66          */
67         public static Result_RouteDecodeErrorZ read(byte[] ser) {
68                 long ret = bindings.Route_read(ser);
69                 Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);
70                 return ret_hu_conv;
71         }
72
73 }