X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FRoute.java;h=6aad4ee74d3e865bd2d8d4ec3527aa8a7da3e170;hb=8c0814bf345323be8f16e075a9af0bd43d9400ee;hp=5d0515532004c3b97b0f7b3a1616bf50c75150c0;hpb=ba1af51214a8ea2de62b84cd23b6145173c71752;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Route.java b/src/main/java/org/ldk/structs/Route.java index 5d051553..6aad4ee7 100644 --- a/src/main/java/org/ldk/structs/Route.java +++ b/src/main/java/org/ldk/structs/Route.java @@ -20,6 +20,31 @@ public class Route extends CommonBase { if (ptr != 0) { bindings.Route_free(ptr); } } + /** + * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the + * last RouteHop in each path must be the same. + * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the + * destination. Thus, this must always be at least length one. While the maximum length of any + * given path is variable, keeping the length of any path to less than 20 should currently + * ensure it is viable. + */ + public RouteHop[][] get_paths() { + long[][] ret = bindings.Route_get_paths(this.ptr); + RouteHop[][] ret_conv_12_arr = new RouteHop[ret.length][]; + for (int m = 0; m < ret.length; m++) { + long[] ret_conv_12 = ret[m]; + RouteHop[] ret_conv_12_conv_10_arr = new RouteHop[ret_conv_12.length]; + for (int k = 0; k < ret_conv_12.length; k++) { + long ret_conv_12_conv_10 = ret_conv_12[k]; + RouteHop ret_conv_12_conv_10_hu_conv = new RouteHop(null, ret_conv_12_conv_10); + ret_conv_12_conv_10_hu_conv.ptrs_to.add(this); + ret_conv_12_conv_10_arr[k] = ret_conv_12_conv_10_hu_conv; + } + ret_conv_12_arr[m] = ret_conv_12_conv_10_arr; + } + return ret_conv_12_arr; + } + /** * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the * last RouteHop in each path must be the same. @@ -30,7 +55,6 @@ public class Route extends CommonBase { */ public void set_paths(RouteHop[][] val) { bindings.Route_set_paths(this.ptr, val != null ? Arrays.stream(val).map(val_conv_12 -> val_conv_12 != null ? 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() : null).toArray(long[][]::new) : null); - /* TODO 2 RouteHop[] */; } /** @@ -41,7 +65,6 @@ public class Route extends CommonBase { if (ret < 1024) { return null; } Route ret_hu_conv = new Route(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 RouteHop[] */; return ret_hu_conv; } @@ -56,6 +79,44 @@ public class Route extends CommonBase { return ret_hu_conv; } + /** + * Checks if two Routes contain equal inner contents. + */ + public long hash() { + long ret = bindings.Route_hash(this.ptr); + return ret; + } + + /** + * Checks if two Routes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(Route b) { + boolean ret = bindings.Route_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + + /** + * Returns the total amount of fees paid on this [`Route`]. + * + * This doesn't include any extra payment made to the recipient, which can happen in excess of + * the amount passed to [`get_route`]'s `final_value_msat`. + */ + public long get_total_fees() { + long ret = bindings.Route_get_total_fees(this.ptr); + return ret; + } + + /** + * Returns the total amount paid on this [`Route`], excluding the fees. + */ + public long get_total_amount() { + long ret = bindings.Route_get_total_amount(this.ptr); + return ret; + } + /** * Serialize the Route object into a byte array which can be read by Route_read */