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;
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RouteHop extends CommonBase {
16 RouteHop(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.RouteHop_free(ptr); }
24 * The node_id of the node at this hop.
26 public byte[] get_pubkey() {
27 byte[] ret = bindings.RouteHop_get_pubkey(this.ptr);
28 Reference.reachabilityFence(this);
33 * The node_id of the node at this hop.
35 public void set_pubkey(byte[] val) {
36 bindings.RouteHop_set_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The node_announcement features of the node at this hop. For the last hop, these may be
43 * amended to match the features present in the invoice this node generated.
45 public NodeFeatures get_node_features() {
46 long ret = bindings.RouteHop_get_node_features(this.ptr);
47 Reference.reachabilityFence(this);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
50 ret_hu_conv.ptrs_to.add(this);
55 * The node_announcement features of the node at this hop. For the last hop, these may be
56 * amended to match the features present in the invoice this node generated.
58 public void set_node_features(NodeFeatures val) {
59 bindings.RouteHop_set_node_features(this.ptr, val == null ? 0 : val.ptr & ~1);
60 Reference.reachabilityFence(this);
61 Reference.reachabilityFence(val);
65 * The channel that should be used from the previous hop to reach this node.
67 public long get_short_channel_id() {
68 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
69 Reference.reachabilityFence(this);
74 * The channel that should be used from the previous hop to reach this node.
76 public void set_short_channel_id(long val) {
77 bindings.RouteHop_set_short_channel_id(this.ptr, val);
78 Reference.reachabilityFence(this);
79 Reference.reachabilityFence(val);
83 * The channel_announcement features of the channel that should be used from the previous hop
86 public ChannelFeatures get_channel_features() {
87 long ret = bindings.RouteHop_get_channel_features(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
91 ret_hu_conv.ptrs_to.add(this);
96 * The channel_announcement features of the channel that should be used from the previous hop
99 public void set_channel_features(ChannelFeatures val) {
100 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr & ~1);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(val);
106 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
107 * For the last hop, this should be the full value of the payment (might be more than
108 * requested if we had to match htlc_minimum_msat).
110 public long get_fee_msat() {
111 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
112 Reference.reachabilityFence(this);
117 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
118 * For the last hop, this should be the full value of the payment (might be more than
119 * requested if we had to match htlc_minimum_msat).
121 public void set_fee_msat(long val) {
122 bindings.RouteHop_set_fee_msat(this.ptr, val);
123 Reference.reachabilityFence(this);
124 Reference.reachabilityFence(val);
128 * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
129 * expected at the destination, in excess of the current block height.
131 public int get_cltv_expiry_delta() {
132 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
133 Reference.reachabilityFence(this);
138 * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
139 * expected at the destination, in excess of the current block height.
141 public void set_cltv_expiry_delta(int val) {
142 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
143 Reference.reachabilityFence(this);
144 Reference.reachabilityFence(val);
148 * Constructs a new RouteHop given each field
150 public static RouteHop of(byte[] pubkey_arg, NodeFeatures node_features_arg, long short_channel_id_arg, ChannelFeatures channel_features_arg, long fee_msat_arg, int cltv_expiry_delta_arg) {
151 long ret = bindings.RouteHop_new(InternalUtils.check_arr_len(pubkey_arg, 33), node_features_arg == null ? 0 : node_features_arg.ptr & ~1, short_channel_id_arg, channel_features_arg == null ? 0 : channel_features_arg.ptr & ~1, fee_msat_arg, cltv_expiry_delta_arg);
152 Reference.reachabilityFence(pubkey_arg);
153 Reference.reachabilityFence(node_features_arg);
154 Reference.reachabilityFence(short_channel_id_arg);
155 Reference.reachabilityFence(channel_features_arg);
156 Reference.reachabilityFence(fee_msat_arg);
157 Reference.reachabilityFence(cltv_expiry_delta_arg);
158 if (ret >= 0 && ret <= 4096) { return null; }
159 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
160 ret_hu_conv.ptrs_to.add(ret_hu_conv);
165 long ret = bindings.RouteHop_clone_ptr(this.ptr);
166 Reference.reachabilityFence(this);
171 * Creates a copy of the RouteHop
173 public RouteHop clone() {
174 long ret = bindings.RouteHop_clone(this.ptr);
175 Reference.reachabilityFence(this);
176 if (ret >= 0 && ret <= 4096) { return null; }
177 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
178 ret_hu_conv.ptrs_to.add(this);
183 * Checks if two RouteHops contain equal inner contents.
186 long ret = bindings.RouteHop_hash(this.ptr);
187 Reference.reachabilityFence(this);
191 @Override public int hashCode() {
192 return (int)this.hash();
195 * Checks if two RouteHops contain equal inner contents.
196 * This ignores pointers and is_owned flags and looks at the values in fields.
197 * Two objects with NULL inner values will be considered "equal" here.
199 public boolean eq(RouteHop b) {
200 boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
201 Reference.reachabilityFence(this);
202 Reference.reachabilityFence(b);
207 @Override public boolean equals(Object o) {
208 if (!(o instanceof RouteHop)) return false;
209 return this.eq((RouteHop)o);
212 * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
214 public byte[] write() {
215 byte[] ret = bindings.RouteHop_write(this.ptr);
216 Reference.reachabilityFence(this);
221 * Read a RouteHop from a byte array, created by RouteHop_write
223 public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
224 long ret = bindings.RouteHop_read(ser);
225 Reference.reachabilityFence(ser);
226 if (ret >= 0 && ret <= 4096) { return null; }
227 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);