Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / RouteParameters.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 import javax.annotation.Nullable;
8
9
10 /**
11  * Parameters needed to find a [`Route`] for paying a [`Payee`].
12  * 
13  * Passed to [`find_route`] and also provided in [`Event::PaymentPathFailed`] for retrying a failed
14  * payment path.
15  * 
16  * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
17  */
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 {
23                 super.finalize();
24                 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
25         }
26
27         /**
28          * The recipient of the failed payment path.
29          */
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);
35                 return ret_hu_conv;
36         }
37
38         /**
39          * The recipient of the failed payment path.
40          */
41         public void set_payee(Payee val) {
42                 bindings.RouteParameters_set_payee(this.ptr, val == null ? 0 : val.ptr & ~1);
43         }
44
45         /**
46          * The amount in msats sent on the failed payment path.
47          */
48         public long get_final_value_msat() {
49                 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
50                 return ret;
51         }
52
53         /**
54          * The amount in msats sent on the failed payment path.
55          */
56         public void set_final_value_msat(long val) {
57                 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
58         }
59
60         /**
61          * The CLTV on the final hop of the failed payment path.
62          */
63         public int get_final_cltv_expiry_delta() {
64                 int ret = bindings.RouteParameters_get_final_cltv_expiry_delta(this.ptr);
65                 return ret;
66         }
67
68         /**
69          * The CLTV on the final hop of the failed payment path.
70          */
71         public void set_final_cltv_expiry_delta(int val) {
72                 bindings.RouteParameters_set_final_cltv_expiry_delta(this.ptr, val);
73         }
74
75         /**
76          * Constructs a new RouteParameters given each field
77          */
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);
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Creates a copy of the RouteParameters
88          */
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);
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
99          */
100         public byte[] write() {
101                 byte[] ret = bindings.RouteParameters_write(this.ptr);
102                 return ret;
103         }
104
105         /**
106          * Read a RouteParameters from a byte array, created by RouteParameters_write
107          */
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);
112                 return ret_hu_conv;
113         }
114
115 }