d0cbcb9492074b8a918274cd26bcaeb284913863
[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                 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
67                 if (ret_hu_conv != null) { 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(org.ldk.structs.RoutingFees val) {
75                 bindings.RouteHintHop_set_fees(this.ptr, val == null ? 0 : val.ptr);
76                 Reference.reachabilityFence(this);
77                 Reference.reachabilityFence(val);
78                 if (this != null) { this.ptrs_to.add(val); };
79         }
80
81         /**
82          * The difference in CLTV values between this node and the next node.
83          */
84         public short get_cltv_expiry_delta() {
85                 short ret = bindings.RouteHintHop_get_cltv_expiry_delta(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * The difference in CLTV values between this node and the next node.
92          */
93         public void set_cltv_expiry_delta(short val) {
94                 bindings.RouteHintHop_set_cltv_expiry_delta(this.ptr, val);
95                 Reference.reachabilityFence(this);
96                 Reference.reachabilityFence(val);
97         }
98
99         /**
100          * The minimum value, in msat, which must be relayed to the next hop.
101          */
102         public Option_u64Z get_htlc_minimum_msat() {
103                 long ret = bindings.RouteHintHop_get_htlc_minimum_msat(this.ptr);
104                 Reference.reachabilityFence(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * The minimum value, in msat, which must be relayed to the next hop.
113          */
114         public void set_htlc_minimum_msat(org.ldk.structs.Option_u64Z val) {
115                 bindings.RouteHintHop_set_htlc_minimum_msat(this.ptr, val.ptr);
116                 Reference.reachabilityFence(this);
117                 Reference.reachabilityFence(val);
118                 if (this != null) { this.ptrs_to.add(val); };
119         }
120
121         /**
122          * The maximum value in msat available for routing with a single HTLC.
123          */
124         public Option_u64Z get_htlc_maximum_msat() {
125                 long ret = bindings.RouteHintHop_get_htlc_maximum_msat(this.ptr);
126                 Reference.reachabilityFence(this);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
130                 return ret_hu_conv;
131         }
132
133         /**
134          * The maximum value in msat available for routing with a single HTLC.
135          */
136         public void set_htlc_maximum_msat(org.ldk.structs.Option_u64Z val) {
137                 bindings.RouteHintHop_set_htlc_maximum_msat(this.ptr, val.ptr);
138                 Reference.reachabilityFence(this);
139                 Reference.reachabilityFence(val);
140                 if (this != null) { this.ptrs_to.add(val); };
141         }
142
143         /**
144          * Constructs a new RouteHintHop given each field
145          */
146         public static RouteHintHop of(byte[] src_node_id_arg, long short_channel_id_arg, org.ldk.structs.RoutingFees fees_arg, short cltv_expiry_delta_arg, org.ldk.structs.Option_u64Z htlc_minimum_msat_arg, org.ldk.structs.Option_u64Z htlc_maximum_msat_arg) {
147                 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, cltv_expiry_delta_arg, htlc_minimum_msat_arg.ptr, htlc_maximum_msat_arg.ptr);
148                 Reference.reachabilityFence(src_node_id_arg);
149                 Reference.reachabilityFence(short_channel_id_arg);
150                 Reference.reachabilityFence(fees_arg);
151                 Reference.reachabilityFence(cltv_expiry_delta_arg);
152                 Reference.reachabilityFence(htlc_minimum_msat_arg);
153                 Reference.reachabilityFence(htlc_maximum_msat_arg);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHintHop(null, ret); }
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fees_arg); };
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(htlc_minimum_msat_arg); };
159                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(htlc_maximum_msat_arg); };
160                 return ret_hu_conv;
161         }
162
163         long clone_ptr() {
164                 long ret = bindings.RouteHintHop_clone_ptr(this.ptr);
165                 Reference.reachabilityFence(this);
166                 return ret;
167         }
168
169         /**
170          * Creates a copy of the RouteHintHop
171          */
172         public RouteHintHop clone() {
173                 long ret = bindings.RouteHintHop_clone(this.ptr);
174                 Reference.reachabilityFence(this);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHintHop(null, ret); }
177                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
178                 return ret_hu_conv;
179         }
180
181         /**
182          * Generates a non-cryptographic 64-bit hash of the RouteHintHop.
183          */
184         public long hash() {
185                 long ret = bindings.RouteHintHop_hash(this.ptr);
186                 Reference.reachabilityFence(this);
187                 return ret;
188         }
189
190         @Override public int hashCode() {
191                 return (int)this.hash();
192         }
193         /**
194          * Checks if two RouteHintHops contain equal inner contents.
195          * This ignores pointers and is_owned flags and looks at the values in fields.
196          * Two objects with NULL inner values will be considered "equal" here.
197          */
198         public boolean eq(org.ldk.structs.RouteHintHop b) {
199                 boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr);
200                 Reference.reachabilityFence(this);
201                 Reference.reachabilityFence(b);
202                 if (this != null) { this.ptrs_to.add(b); };
203                 return ret;
204         }
205
206         @Override public boolean equals(Object o) {
207                 if (!(o instanceof RouteHintHop)) return false;
208                 return this.eq((RouteHintHop)o);
209         }
210         /**
211          * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
212          */
213         public byte[] write() {
214                 byte[] ret = bindings.RouteHintHop_write(this.ptr);
215                 Reference.reachabilityFence(this);
216                 return ret;
217         }
218
219         /**
220          * Read a RouteHintHop from a byte array, created by RouteHintHop_write
221          */
222         public static Result_RouteHintHopDecodeErrorZ read(byte[] ser) {
223                 long ret = bindings.RouteHintHop_read(ser);
224                 Reference.reachabilityFence(ser);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
227                 return ret_hu_conv;
228         }
229
230 }