X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FRouteParameters.java;h=f81e9b7be4d9dc986e0d0a846671b4ba74c5d433;hb=ffdd56c967087cba7548599934585b8a9a3102e2;hp=0d4ac69972d65962b2ac560c860d6777d8ebcbca;hpb=330ca992be304d0eac79bd59b411980dff294b03;p=ldk-java diff --git a/src/main/java/org/ldk/structs/RouteParameters.java b/src/main/java/org/ldk/structs/RouteParameters.java index 0d4ac699..f81e9b7b 100644 --- a/src/main/java/org/ldk/structs/RouteParameters.java +++ b/src/main/java/org/ldk/structs/RouteParameters.java @@ -11,10 +11,7 @@ import javax.annotation.Nullable; /** * Parameters needed to find a [`Route`]. * - * Passed to [`find_route`] and [`build_route_from_hops`], but also provided in - * [`Event::PaymentPathFailed`] for retrying a failed payment path. - * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed + * Passed to [`find_route`] and [`build_route_from_hops`]. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class RouteParameters extends CommonBase { @@ -41,7 +38,7 @@ public class RouteParameters extends CommonBase { * The parameters of the failed payment path. */ public void set_payment_params(org.ldk.structs.PaymentParameters val) { - bindings.RouteParameters_set_payment_params(this.ptr, val == null ? 0 : val.ptr); + bindings.RouteParameters_set_payment_params(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); if (this != null) { this.ptrs_to.add(val); }; @@ -66,35 +63,50 @@ public class RouteParameters extends CommonBase { } /** - * The CLTV on the final hop of the failed payment path. + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. */ - public int get_final_cltv_expiry_delta() { - int ret = bindings.RouteParameters_get_final_cltv_expiry_delta(this.ptr); + public Option_u64Z get_max_total_routing_fee_msat() { + long ret = bindings.RouteParameters_get_max_total_routing_fee_msat(this.ptr); Reference.reachabilityFence(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** - * The CLTV on the final hop of the failed payment path. + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. */ - public void set_final_cltv_expiry_delta(int val) { - bindings.RouteParameters_set_final_cltv_expiry_delta(this.ptr, val); + public void set_max_total_routing_fee_msat(org.ldk.structs.Option_u64Z val) { + bindings.RouteParameters_set_max_total_routing_fee_msat(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** * Constructs a new RouteParameters given each field */ - public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg, int final_cltv_expiry_delta_arg) { - long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg, final_cltv_expiry_delta_arg); + public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg, org.ldk.structs.Option_u64Z max_total_routing_fee_msat_arg) { + long ret = bindings.RouteParameters_new(payment_params_arg.ptr, final_value_msat_arg, max_total_routing_fee_msat_arg.ptr); Reference.reachabilityFence(payment_params_arg); Reference.reachabilityFence(final_value_msat_arg); - Reference.reachabilityFence(final_cltv_expiry_delta_arg); + Reference.reachabilityFence(max_total_routing_fee_msat_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_params_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(max_total_routing_fee_msat_arg); }; return ret_hu_conv; } @@ -116,6 +128,51 @@ public class RouteParameters extends CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the RouteParameters. + */ + public long hash() { + long ret = bindings.RouteParameters_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } + /** + * Checks if two RouteParameterss 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(org.ldk.structs.RouteParameters b) { + boolean ret = bindings.RouteParameters_eq(this.ptr, b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + if (this != null) { this.ptrs_to.add(b); }; + return ret; + } + + @Override public boolean equals(Object o) { + if (!(o instanceof RouteParameters)) return false; + return this.eq((RouteParameters)o); + } + /** + * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. + * + * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats + */ + public static RouteParameters from_payment_params_and_value(org.ldk.structs.PaymentParameters payment_params, long final_value_msat) { + long ret = bindings.RouteParameters_from_payment_params_and_value(payment_params.ptr, final_value_msat); + Reference.reachabilityFence(payment_params); + Reference.reachabilityFence(final_value_msat); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_params); }; + return ret_hu_conv; + } + /** * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read */