[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / RouteHop.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 hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel
13  * that leads to it.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class RouteHop extends CommonBase {
17         RouteHop(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.RouteHop_free(ptr); }
22         }
23
24         /**
25          * The node_id of the node at this hop.
26          */
27         public byte[] get_pubkey() {
28                 byte[] ret = bindings.RouteHop_get_pubkey(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * The node_id of the node at this hop.
35          */
36         public void set_pubkey(byte[] val) {
37                 bindings.RouteHop_set_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
38                 Reference.reachabilityFence(this);
39                 Reference.reachabilityFence(val);
40         }
41
42         /**
43          * The node_announcement features of the node at this hop. For the last hop, these may be
44          * amended to match the features present in the invoice this node generated.
45          */
46         public NodeFeatures get_node_features() {
47                 long ret = bindings.RouteHop_get_node_features(this.ptr);
48                 Reference.reachabilityFence(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The node_announcement features of the node at this hop. For the last hop, these may be
57          * amended to match the features present in the invoice this node generated.
58          */
59         public void set_node_features(org.ldk.structs.NodeFeatures val) {
60                 bindings.RouteHop_set_node_features(this.ptr, val == null ? 0 : val.ptr);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63                 if (this != null) { this.ptrs_to.add(val); };
64         }
65
66         /**
67          * The channel that should be used from the previous hop to reach this node.
68          */
69         public long get_short_channel_id() {
70                 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
71                 Reference.reachabilityFence(this);
72                 return ret;
73         }
74
75         /**
76          * The channel that should be used from the previous hop to reach this node.
77          */
78         public void set_short_channel_id(long val) {
79                 bindings.RouteHop_set_short_channel_id(this.ptr, val);
80                 Reference.reachabilityFence(this);
81                 Reference.reachabilityFence(val);
82         }
83
84         /**
85          * The channel_announcement features of the channel that should be used from the previous hop
86          * to reach this node.
87          */
88         public ChannelFeatures get_channel_features() {
89                 long ret = bindings.RouteHop_get_channel_features(this.ptr);
90                 Reference.reachabilityFence(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * The channel_announcement features of the channel that should be used from the previous hop
99          * to reach this node.
100          */
101         public void set_channel_features(org.ldk.structs.ChannelFeatures val) {
102                 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105                 if (this != null) { this.ptrs_to.add(val); };
106         }
107
108         /**
109          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
110          * If this is the last hop in [`Path::hops`]:
111          * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
112          * otherwise, this is the full value of this [`Path`]'s part of the payment
113          * 
114          * [`BlindedPath`]: crate::blinded_path::BlindedPath
115          */
116         public long get_fee_msat() {
117                 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
118                 Reference.reachabilityFence(this);
119                 return ret;
120         }
121
122         /**
123          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
124          * If this is the last hop in [`Path::hops`]:
125          * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
126          * otherwise, this is the full value of this [`Path`]'s part of the payment
127          * 
128          * [`BlindedPath`]: crate::blinded_path::BlindedPath
129          */
130         public void set_fee_msat(long val) {
131                 bindings.RouteHop_set_fee_msat(this.ptr, val);
132                 Reference.reachabilityFence(this);
133                 Reference.reachabilityFence(val);
134         }
135
136         /**
137          * The CLTV delta added for this hop.
138          * If this is the last hop in [`Path::hops`]:
139          * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
140          * otherwise, this is the CLTV delta expected at the destination
141          * 
142          * [`BlindedPath`]: crate::blinded_path::BlindedPath
143          */
144         public int get_cltv_expiry_delta() {
145                 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
146                 Reference.reachabilityFence(this);
147                 return ret;
148         }
149
150         /**
151          * The CLTV delta added for this hop.
152          * If this is the last hop in [`Path::hops`]:
153          * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
154          * otherwise, this is the CLTV delta expected at the destination
155          * 
156          * [`BlindedPath`]: crate::blinded_path::BlindedPath
157          */
158         public void set_cltv_expiry_delta(int val) {
159                 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
160                 Reference.reachabilityFence(this);
161                 Reference.reachabilityFence(val);
162         }
163
164         /**
165          * Indicates whether this hop is possibly announced in the public network graph.
166          * 
167          * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
168          * either know for sure it's announced in the public graph, or if any public channels exist
169          * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
170          * the channel to be unannounced.
171          * 
172          * Will be `true` for objects serialized with LDK version 0.0.116 and before.
173          */
174         public boolean get_maybe_announced_channel() {
175                 boolean ret = bindings.RouteHop_get_maybe_announced_channel(this.ptr);
176                 Reference.reachabilityFence(this);
177                 return ret;
178         }
179
180         /**
181          * Indicates whether this hop is possibly announced in the public network graph.
182          * 
183          * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
184          * either know for sure it's announced in the public graph, or if any public channels exist
185          * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
186          * the channel to be unannounced.
187          * 
188          * Will be `true` for objects serialized with LDK version 0.0.116 and before.
189          */
190         public void set_maybe_announced_channel(boolean val) {
191                 bindings.RouteHop_set_maybe_announced_channel(this.ptr, val);
192                 Reference.reachabilityFence(this);
193                 Reference.reachabilityFence(val);
194         }
195
196         /**
197          * Constructs a new RouteHop given each field
198          */
199         public static RouteHop of(byte[] pubkey_arg, org.ldk.structs.NodeFeatures node_features_arg, long short_channel_id_arg, org.ldk.structs.ChannelFeatures channel_features_arg, long fee_msat_arg, int cltv_expiry_delta_arg, boolean maybe_announced_channel_arg) {
200                 long ret = bindings.RouteHop_new(InternalUtils.check_arr_len(pubkey_arg, 33), node_features_arg == null ? 0 : node_features_arg.ptr, short_channel_id_arg, channel_features_arg == null ? 0 : channel_features_arg.ptr, fee_msat_arg, cltv_expiry_delta_arg, maybe_announced_channel_arg);
201                 Reference.reachabilityFence(pubkey_arg);
202                 Reference.reachabilityFence(node_features_arg);
203                 Reference.reachabilityFence(short_channel_id_arg);
204                 Reference.reachabilityFence(channel_features_arg);
205                 Reference.reachabilityFence(fee_msat_arg);
206                 Reference.reachabilityFence(cltv_expiry_delta_arg);
207                 Reference.reachabilityFence(maybe_announced_channel_arg);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_features_arg); };
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_features_arg); };
213                 return ret_hu_conv;
214         }
215
216         long clone_ptr() {
217                 long ret = bindings.RouteHop_clone_ptr(this.ptr);
218                 Reference.reachabilityFence(this);
219                 return ret;
220         }
221
222         /**
223          * Creates a copy of the RouteHop
224          */
225         public RouteHop clone() {
226                 long ret = bindings.RouteHop_clone(this.ptr);
227                 Reference.reachabilityFence(this);
228                 if (ret >= 0 && ret <= 4096) { return null; }
229                 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
230                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
231                 return ret_hu_conv;
232         }
233
234         /**
235          * Generates a non-cryptographic 64-bit hash of the RouteHop.
236          */
237         public long hash() {
238                 long ret = bindings.RouteHop_hash(this.ptr);
239                 Reference.reachabilityFence(this);
240                 return ret;
241         }
242
243         @Override public int hashCode() {
244                 return (int)this.hash();
245         }
246         /**
247          * Checks if two RouteHops contain equal inner contents.
248          * This ignores pointers and is_owned flags and looks at the values in fields.
249          * Two objects with NULL inner values will be considered "equal" here.
250          */
251         public boolean eq(org.ldk.structs.RouteHop b) {
252                 boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr);
253                 Reference.reachabilityFence(this);
254                 Reference.reachabilityFence(b);
255                 if (this != null) { this.ptrs_to.add(b); };
256                 return ret;
257         }
258
259         @Override public boolean equals(Object o) {
260                 if (!(o instanceof RouteHop)) return false;
261                 return this.eq((RouteHop)o);
262         }
263         /**
264          * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
265          */
266         public byte[] write() {
267                 byte[] ret = bindings.RouteHop_write(this.ptr);
268                 Reference.reachabilityFence(this);
269                 return ret;
270         }
271
272         /**
273          * Read a RouteHop from a byte array, created by RouteHop_write
274          */
275         public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
276                 long ret = bindings.RouteHop_read(ser);
277                 Reference.reachabilityFence(ser);
278                 if (ret >= 0 && ret <= 4096) { return null; }
279                 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
280                 return ret_hu_conv;
281         }
282
283 }