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