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 if (ret_hu_conv != null) { 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);
60 Reference.reachabilityFence(this);
61 Reference.reachabilityFence(val);
62 if (this != null) { this.ptrs_to.add(val); };
66 * The channel that should be used from the previous hop to reach this node.
68 public long get_short_channel_id() {
69 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
70 Reference.reachabilityFence(this);
75 * The channel that should be used from the previous hop to reach this node.
77 public void set_short_channel_id(long val) {
78 bindings.RouteHop_set_short_channel_id(this.ptr, val);
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * The channel_announcement features of the channel that should be used from the previous hop
87 public ChannelFeatures get_channel_features() {
88 long ret = bindings.RouteHop_get_channel_features(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97 * The channel_announcement features of the channel that should be used from the previous hop
100 public void set_channel_features(ChannelFeatures val) {
101 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr);
102 Reference.reachabilityFence(this);
103 Reference.reachabilityFence(val);
104 if (this != null) { this.ptrs_to.add(val); };
108 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
109 * For the last hop, this should be the full value of the payment (might be more than
110 * requested if we had to match htlc_minimum_msat).
112 public long get_fee_msat() {
113 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
114 Reference.reachabilityFence(this);
119 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
120 * For the last hop, this should be the full value of the payment (might be more than
121 * requested if we had to match htlc_minimum_msat).
123 public void set_fee_msat(long val) {
124 bindings.RouteHop_set_fee_msat(this.ptr, val);
125 Reference.reachabilityFence(this);
126 Reference.reachabilityFence(val);
130 * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
131 * expected at the destination, in excess of the current block height.
133 public int get_cltv_expiry_delta() {
134 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
135 Reference.reachabilityFence(this);
140 * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
141 * expected at the destination, in excess of the current block height.
143 public void set_cltv_expiry_delta(int val) {
144 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
145 Reference.reachabilityFence(this);
146 Reference.reachabilityFence(val);
150 * Constructs a new RouteHop given each field
152 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) {
153 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);
154 Reference.reachabilityFence(pubkey_arg);
155 Reference.reachabilityFence(node_features_arg);
156 Reference.reachabilityFence(short_channel_id_arg);
157 Reference.reachabilityFence(channel_features_arg);
158 Reference.reachabilityFence(fee_msat_arg);
159 Reference.reachabilityFence(cltv_expiry_delta_arg);
160 if (ret >= 0 && ret <= 4096) { return null; }
161 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
162 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
163 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_features_arg); };
164 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_features_arg); };
169 long ret = bindings.RouteHop_clone_ptr(this.ptr);
170 Reference.reachabilityFence(this);
175 * Creates a copy of the RouteHop
177 public RouteHop clone() {
178 long ret = bindings.RouteHop_clone(this.ptr);
179 Reference.reachabilityFence(this);
180 if (ret >= 0 && ret <= 4096) { return null; }
181 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
182 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
187 * Checks if two RouteHops contain equal inner contents.
190 long ret = bindings.RouteHop_hash(this.ptr);
191 Reference.reachabilityFence(this);
195 @Override public int hashCode() {
196 return (int)this.hash();
199 * Checks if two RouteHops contain equal inner contents.
200 * This ignores pointers and is_owned flags and looks at the values in fields.
201 * Two objects with NULL inner values will be considered "equal" here.
203 public boolean eq(RouteHop b) {
204 boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr);
205 Reference.reachabilityFence(this);
206 Reference.reachabilityFence(b);
207 if (this != null) { this.ptrs_to.add(b); };
211 @Override public boolean equals(Object o) {
212 if (!(o instanceof RouteHop)) return false;
213 return this.eq((RouteHop)o);
216 * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
218 public byte[] write() {
219 byte[] ret = bindings.RouteHop_write(this.ptr);
220 Reference.reachabilityFence(this);
225 * Read a RouteHop from a byte array, created by RouteHop_write
227 public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
228 long ret = bindings.RouteHop_read(ser);
229 Reference.reachabilityFence(ser);
230 if (ret >= 0 && ret <= 4096) { return null; }
231 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);