1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
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.
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 {
19 if (ptr != 0) { bindings.Route_free(ptr); }
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.
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[] */;
36 * Constructs a new Route given each field
38 public static Route constructor_new(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[] */;
47 * Creates a copy of the Route
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);
57 * Serialize the Route object into a byte array which can be read by Route_read
59 public byte[] write() {
60 byte[] ret = bindings.Route_write(this.ptr);
65 * Read a Route from a byte array, created by Route_write
67 public static Result_RouteDecodeErrorZ constructor_read(byte[] ser) {
68 long ret = bindings.Route_read(ser);
69 Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);