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 channel descriptor for a hop along a payment path.
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.
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 {
24 if (ptr != 0) { bindings.RouteHintHop_free(ptr); }
28 * The node_id of the non-target end of the route
30 public byte[] get_src_node_id() {
31 byte[] ret = bindings.RouteHintHop_get_src_node_id(this.ptr);
32 Reference.reachabilityFence(this);
37 * The node_id of the non-target end of the route
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);
46 * The short_channel_id of this channel
48 public long get_short_channel_id() {
49 long ret = bindings.RouteHintHop_get_short_channel_id(this.ptr);
50 Reference.reachabilityFence(this);
55 * The short_channel_id of this channel
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);
64 * The fees which must be paid to use this channel
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); };
76 * The fees which must be paid to use this channel
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); };
86 * The difference in CLTV values between this node and the next node.
88 public short get_cltv_expiry_delta() {
89 short ret = bindings.RouteHintHop_get_cltv_expiry_delta(this.ptr);
90 Reference.reachabilityFence(this);
95 * The difference in CLTV values between this node and the next node.
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);
104 * The minimum value, in msat, which must be relayed to the next hop.
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); };
116 * The minimum value, in msat, which must be relayed to the next hop.
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); };
126 * The maximum value in msat available for routing with a single HTLC.
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); };
138 * The maximum value in msat available for routing with a single HTLC.
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); };
148 * Constructs a new RouteHintHop given each field
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); };
168 long ret = bindings.RouteHintHop_clone_ptr(this.ptr);
169 Reference.reachabilityFence(this);
174 * Creates a copy of the RouteHintHop
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); };
186 * Generates a non-cryptographic 64-bit hash of the RouteHintHop.
189 long ret = bindings.RouteHintHop_hash(this.ptr);
190 Reference.reachabilityFence(this);
194 @Override public int hashCode() {
195 return (int)this.hash();
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.
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); };
210 @Override public boolean equals(Object o) {
211 if (!(o instanceof RouteHintHop)) return false;
212 return this.eq((RouteHintHop)o);
215 * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
217 public byte[] write() {
218 byte[] ret = bindings.RouteHintHop_write(this.ptr);
219 Reference.reachabilityFence(this);
224 * Read a RouteHintHop from a byte array, created by RouteHintHop_write
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);