1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Parameters needed to find a [`Route`] for paying a [`Payee`].
13 * Passed to [`find_route`] and also provided in [`Event::PaymentPathFailed`] for retrying a failed
16 * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class RouteParameters extends CommonBase {
20 RouteParameters(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
28 * The recipient of the failed payment path.
30 public Payee get_payee() {
31 long ret = bindings.RouteParameters_get_payee(this.ptr);
32 if (ret >= 0 && ret <= 4096) { return null; }
33 Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
34 ret_hu_conv.ptrs_to.add(this);
39 * The recipient of the failed payment path.
41 public void set_payee(Payee val) {
42 bindings.RouteParameters_set_payee(this.ptr, val == null ? 0 : val.ptr & ~1);
46 * The amount in msats sent on the failed payment path.
48 public long get_final_value_msat() {
49 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
54 * The amount in msats sent on the failed payment path.
56 public void set_final_value_msat(long val) {
57 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
61 * The CLTV on the final hop of the failed payment path.
63 public int get_final_cltv_expiry_delta() {
64 int ret = bindings.RouteParameters_get_final_cltv_expiry_delta(this.ptr);
69 * The CLTV on the final hop of the failed payment path.
71 public void set_final_cltv_expiry_delta(int val) {
72 bindings.RouteParameters_set_final_cltv_expiry_delta(this.ptr, val);
76 * Constructs a new RouteParameters given each field
78 public static RouteParameters of(Payee payee_arg, long final_value_msat_arg, int final_cltv_expiry_delta_arg) {
79 long ret = bindings.RouteParameters_new(payee_arg == null ? 0 : payee_arg.ptr & ~1, final_value_msat_arg, final_cltv_expiry_delta_arg);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteParameters(null, ret); }
82 ret_hu_conv.ptrs_to.add(ret_hu_conv);
87 * Creates a copy of the RouteParameters
89 public RouteParameters clone() {
90 long ret = bindings.RouteParameters_clone(this.ptr);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteParameters(null, ret); }
93 ret_hu_conv.ptrs_to.add(this);
98 * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
100 public byte[] write() {
101 byte[] ret = bindings.RouteParameters_write(this.ptr);
106 * Read a RouteParameters from a byte array, created by RouteParameters_write
108 public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
109 long ret = bindings.RouteParameters_read(ser);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);