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 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RouteHintHop extends CommonBase {
16 RouteHintHop(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.RouteHintHop_free(ptr); }
24 * The node_id of the non-target end of the route
26 public byte[] get_src_node_id() {
27 byte[] ret = bindings.RouteHintHop_get_src_node_id(this.ptr);
28 Reference.reachabilityFence(this);
33 * The node_id of the non-target end of the route
35 public void set_src_node_id(byte[] val) {
36 bindings.RouteHintHop_set_src_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The short_channel_id of this channel
44 public long get_short_channel_id() {
45 long ret = bindings.RouteHintHop_get_short_channel_id(this.ptr);
46 Reference.reachabilityFence(this);
51 * The short_channel_id of this channel
53 public void set_short_channel_id(long val) {
54 bindings.RouteHintHop_set_short_channel_id(this.ptr, val);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * The fees which must be paid to use this channel
62 public RoutingFees get_fees() {
63 long ret = bindings.RouteHintHop_get_fees(this.ptr);
64 Reference.reachabilityFence(this);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
67 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
72 * The fees which must be paid to use this channel
74 public void set_fees(RoutingFees val) {
75 bindings.RouteHintHop_set_fees(this.ptr, val == null ? 0 : val.ptr);
76 Reference.reachabilityFence(this);
77 Reference.reachabilityFence(val);
78 if (this != null) { this.ptrs_to.add(val); };
82 * The difference in CLTV values between this node and the next node.
84 public short get_cltv_expiry_delta() {
85 short ret = bindings.RouteHintHop_get_cltv_expiry_delta(this.ptr);
86 Reference.reachabilityFence(this);
91 * The difference in CLTV values between this node and the next node.
93 public void set_cltv_expiry_delta(short val) {
94 bindings.RouteHintHop_set_cltv_expiry_delta(this.ptr, val);
95 Reference.reachabilityFence(this);
96 Reference.reachabilityFence(val);
100 * The minimum value, in msat, which must be relayed to the next hop.
102 public Option_u64Z get_htlc_minimum_msat() {
103 long ret = bindings.RouteHintHop_get_htlc_minimum_msat(this.ptr);
104 Reference.reachabilityFence(this);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
112 * The minimum value, in msat, which must be relayed to the next hop.
114 public void set_htlc_minimum_msat(Option_u64Z val) {
115 bindings.RouteHintHop_set_htlc_minimum_msat(this.ptr, val.ptr);
116 Reference.reachabilityFence(this);
117 Reference.reachabilityFence(val);
121 * The maximum value in msat available for routing with a single HTLC.
123 public Option_u64Z get_htlc_maximum_msat() {
124 long ret = bindings.RouteHintHop_get_htlc_maximum_msat(this.ptr);
125 Reference.reachabilityFence(this);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133 * The maximum value in msat available for routing with a single HTLC.
135 public void set_htlc_maximum_msat(Option_u64Z val) {
136 bindings.RouteHintHop_set_htlc_maximum_msat(this.ptr, val.ptr);
137 Reference.reachabilityFence(this);
138 Reference.reachabilityFence(val);
142 * Constructs a new RouteHintHop given each field
144 public static RouteHintHop of(byte[] src_node_id_arg, long short_channel_id_arg, RoutingFees fees_arg, short cltv_expiry_delta_arg, Option_u64Z htlc_minimum_msat_arg, Option_u64Z htlc_maximum_msat_arg) {
145 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);
146 Reference.reachabilityFence(src_node_id_arg);
147 Reference.reachabilityFence(short_channel_id_arg);
148 Reference.reachabilityFence(fees_arg);
149 Reference.reachabilityFence(cltv_expiry_delta_arg);
150 Reference.reachabilityFence(htlc_minimum_msat_arg);
151 Reference.reachabilityFence(htlc_maximum_msat_arg);
152 if (ret >= 0 && ret <= 4096) { return null; }
153 org.ldk.structs.RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHintHop(null, ret); }
154 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
155 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fees_arg); };
160 long ret = bindings.RouteHintHop_clone_ptr(this.ptr);
161 Reference.reachabilityFence(this);
166 * Creates a copy of the RouteHintHop
168 public RouteHintHop clone() {
169 long ret = bindings.RouteHintHop_clone(this.ptr);
170 Reference.reachabilityFence(this);
171 if (ret >= 0 && ret <= 4096) { return null; }
172 org.ldk.structs.RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHintHop(null, ret); }
173 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
178 * Checks if two RouteHintHops contain equal inner contents.
181 long ret = bindings.RouteHintHop_hash(this.ptr);
182 Reference.reachabilityFence(this);
186 @Override public int hashCode() {
187 return (int)this.hash();
190 * Checks if two RouteHintHops contain equal inner contents.
191 * This ignores pointers and is_owned flags and looks at the values in fields.
192 * Two objects with NULL inner values will be considered "equal" here.
194 public boolean eq(RouteHintHop b) {
195 boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr);
196 Reference.reachabilityFence(this);
197 Reference.reachabilityFence(b);
198 if (this != null) { this.ptrs_to.add(b); };
202 @Override public boolean equals(Object o) {
203 if (!(o instanceof RouteHintHop)) return false;
204 return this.eq((RouteHintHop)o);
207 * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
209 public byte[] write() {
210 byte[] ret = bindings.RouteHintHop_write(this.ptr);
211 Reference.reachabilityFence(this);
216 * Read a RouteHintHop from a byte array, created by RouteHintHop_write
218 public static Result_RouteHintHopDecodeErrorZ read(byte[] ser) {
219 long ret = bindings.RouteHintHop_read(ser);
220 Reference.reachabilityFence(ser);
221 if (ret >= 0 && ret <= 4096) { return null; }
222 Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);