[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / RouteHintHop.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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A channel descriptor for a hop along a payment path.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RouteHintHop extends CommonBase {
16         RouteHintHop(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.RouteHintHop_free(ptr); }
21         }
22
23         /**
24          * The node_id of the non-target end of the route
25          */
26         public byte[] get_src_node_id() {
27                 byte[] ret = bindings.RouteHintHop_get_src_node_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The node_id of the non-target end of the route
34          */
35         public void set_src_node_id(byte[] val) {
36                 bindings.RouteHintHop_set_src_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The short_channel_id of this channel
43          */
44         public long get_short_channel_id() {
45                 long ret = bindings.RouteHintHop_get_short_channel_id(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * The short_channel_id of this channel
52          */
53         public void set_short_channel_id(long val) {
54                 bindings.RouteHintHop_set_short_channel_id(this.ptr, val);
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * The fees which must be paid to use this channel
61          */
62         public RoutingFees get_fees() {
63                 long ret = bindings.RouteHintHop_get_fees(this.ptr);
64                 Reference.reachabilityFence(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
67                 ret_hu_conv.ptrs_to.add(this);
68                 return ret_hu_conv;
69         }
70
71         /**
72          * The fees which must be paid to use this channel
73          */
74         public void set_fees(RoutingFees val) {
75                 bindings.RouteHintHop_set_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
76                 Reference.reachabilityFence(this);
77                 Reference.reachabilityFence(val);
78         }
79
80         /**
81          * The difference in CLTV values between this node and the next node.
82          */
83         public short get_cltv_expiry_delta() {
84                 short ret = bindings.RouteHintHop_get_cltv_expiry_delta(this.ptr);
85                 Reference.reachabilityFence(this);
86                 return ret;
87         }
88
89         /**
90          * The difference in CLTV values between this node and the next node.
91          */
92         public void set_cltv_expiry_delta(short val) {
93                 bindings.RouteHintHop_set_cltv_expiry_delta(this.ptr, val);
94                 Reference.reachabilityFence(this);
95                 Reference.reachabilityFence(val);
96         }
97
98         /**
99          * The minimum value, in msat, which must be relayed to the next hop.
100          */
101         public Option_u64Z get_htlc_minimum_msat() {
102                 long ret = bindings.RouteHintHop_get_htlc_minimum_msat(this.ptr);
103                 Reference.reachabilityFence(this);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
106                 ret_hu_conv.ptrs_to.add(this);
107                 return ret_hu_conv;
108         }
109
110         /**
111          * The minimum value, in msat, which must be relayed to the next hop.
112          */
113         public void set_htlc_minimum_msat(Option_u64Z val) {
114                 bindings.RouteHintHop_set_htlc_minimum_msat(this.ptr, val.ptr);
115                 Reference.reachabilityFence(this);
116                 Reference.reachabilityFence(val);
117         }
118
119         /**
120          * The maximum value in msat available for routing with a single HTLC.
121          */
122         public Option_u64Z get_htlc_maximum_msat() {
123                 long ret = bindings.RouteHintHop_get_htlc_maximum_msat(this.ptr);
124                 Reference.reachabilityFence(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
127                 ret_hu_conv.ptrs_to.add(this);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * The maximum value in msat available for routing with a single HTLC.
133          */
134         public void set_htlc_maximum_msat(Option_u64Z val) {
135                 bindings.RouteHintHop_set_htlc_maximum_msat(this.ptr, val.ptr);
136                 Reference.reachabilityFence(this);
137                 Reference.reachabilityFence(val);
138         }
139
140         /**
141          * Constructs a new RouteHintHop given each field
142          */
143         public static RouteHintHop of(byte[] src_node_id_arg, long short_channel_id_arg, RoutingFees fees_arg, short cltv_expiry_delta_arg, Option_u64Z htlc_minimum_msat_arg, Option_u64Z htlc_maximum_msat_arg) {
144                 long ret = bindings.RouteHintHop_new(InternalUtils.check_arr_len(src_node_id_arg, 33), short_channel_id_arg, fees_arg == null ? 0 : fees_arg.ptr & ~1, cltv_expiry_delta_arg, htlc_minimum_msat_arg.ptr, htlc_maximum_msat_arg.ptr);
145                 Reference.reachabilityFence(src_node_id_arg);
146                 Reference.reachabilityFence(short_channel_id_arg);
147                 Reference.reachabilityFence(fees_arg);
148                 Reference.reachabilityFence(cltv_expiry_delta_arg);
149                 Reference.reachabilityFence(htlc_minimum_msat_arg);
150                 Reference.reachabilityFence(htlc_maximum_msat_arg);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHintHop(null, ret); }
153                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
154                 return ret_hu_conv;
155         }
156
157         long clone_ptr() {
158                 long ret = bindings.RouteHintHop_clone_ptr(this.ptr);
159                 Reference.reachabilityFence(this);
160                 return ret;
161         }
162
163         /**
164          * Creates a copy of the RouteHintHop
165          */
166         public RouteHintHop clone() {
167                 long ret = bindings.RouteHintHop_clone(this.ptr);
168                 Reference.reachabilityFence(this);
169                 if (ret >= 0 && ret <= 4096) { return null; }
170                 RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHintHop(null, ret); }
171                 ret_hu_conv.ptrs_to.add(this);
172                 return ret_hu_conv;
173         }
174
175         /**
176          * Checks if two RouteHintHops contain equal inner contents.
177          */
178         public long hash() {
179                 long ret = bindings.RouteHintHop_hash(this.ptr);
180                 Reference.reachabilityFence(this);
181                 return ret;
182         }
183
184         @Override public int hashCode() {
185                 return (int)this.hash();
186         }
187         /**
188          * Checks if two RouteHintHops contain equal inner contents.
189          * This ignores pointers and is_owned flags and looks at the values in fields.
190          * Two objects with NULL inner values will be considered "equal" here.
191          */
192         public boolean eq(RouteHintHop b) {
193                 boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
194                 Reference.reachabilityFence(this);
195                 Reference.reachabilityFence(b);
196                 this.ptrs_to.add(b);
197                 return ret;
198         }
199
200         @Override public boolean equals(Object o) {
201                 if (!(o instanceof RouteHintHop)) return false;
202                 return this.eq((RouteHintHop)o);
203         }
204         /**
205          * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
206          */
207         public byte[] write() {
208                 byte[] ret = bindings.RouteHintHop_write(this.ptr);
209                 Reference.reachabilityFence(this);
210                 return ret;
211         }
212
213         /**
214          * Read a RouteHintHop from a byte array, created by RouteHintHop_write
215          */
216         public static Result_RouteHintHopDecodeErrorZ read(byte[] ser) {
217                 long ret = bindings.RouteHintHop_read(ser);
218                 Reference.reachabilityFence(ser);
219                 if (ret >= 0 && ret <= 4096) { return null; }
220                 Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
221                 return ret_hu_conv;
222         }
223
224 }