1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel
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 {
21 if (ptr != 0) { bindings.RouteHop_free(ptr); }
25 * The node_id of the node at this hop.
27 public byte[] get_pubkey() {
28 byte[] ret = bindings.RouteHop_get_pubkey(this.ptr);
29 Reference.reachabilityFence(this);
34 * The node_id of the node at this hop.
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);
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.
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); };
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.
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); };
67 * The channel that should be used from the previous hop to reach this node.
69 public long get_short_channel_id() {
70 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
71 Reference.reachabilityFence(this);
76 * The channel that should be used from the previous hop to reach this node.
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);
85 * The channel_announcement features of the channel that should be used from the previous hop
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); };
98 * The channel_announcement features of the channel that should be used from the previous hop
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); };
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
114 * [`BlindedPath`]: crate::blinded_path::BlindedPath
116 public long get_fee_msat() {
117 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
118 Reference.reachabilityFence(this);
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
128 * [`BlindedPath`]: crate::blinded_path::BlindedPath
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);
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
142 * [`BlindedPath`]: crate::blinded_path::BlindedPath
144 public int get_cltv_expiry_delta() {
145 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
146 Reference.reachabilityFence(this);
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
156 * [`BlindedPath`]: crate::blinded_path::BlindedPath
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);
165 * Indicates whether this hop is possibly announced in the public network graph.
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.
172 * Will be `true` for objects serialized with LDK version 0.0.116 and before.
174 public boolean get_maybe_announced_channel() {
175 boolean ret = bindings.RouteHop_get_maybe_announced_channel(this.ptr);
176 Reference.reachabilityFence(this);
181 * Indicates whether this hop is possibly announced in the public network graph.
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.
188 * Will be `true` for objects serialized with LDK version 0.0.116 and before.
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);
197 * Constructs a new RouteHop given each field
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); };
217 long ret = bindings.RouteHop_clone_ptr(this.ptr);
218 Reference.reachabilityFence(this);
223 * Creates a copy of the RouteHop
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); };
235 * Generates a non-cryptographic 64-bit hash of the RouteHop.
238 long ret = bindings.RouteHop_hash(this.ptr);
239 Reference.reachabilityFence(this);
243 @Override public int hashCode() {
244 return (int)this.hash();
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.
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); };
259 @Override public boolean equals(Object o) {
260 if (!(o instanceof RouteHop)) return false;
261 return this.eq((RouteHop)o);
264 * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
266 public byte[] write() {
267 byte[] ret = bindings.RouteHop_write(this.ptr);
268 Reference.reachabilityFence(this);
273 * Read a RouteHop from a byte array, created by RouteHop_write
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);