6 namespace org { namespace ldk { namespace structs {
10 * A hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel
13 public class RouteHop : CommonBase {
14 internal RouteHop(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.RouteHop_free(ptr); }
20 * The node_id of the node at this hop.
22 public byte[] get_pubkey() {
23 long ret = bindings.RouteHop_get_pubkey(this.ptr);
25 if (ret >= 0 && ret <= 4096) { return null; }
26 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
31 * The node_id of the node at this hop.
33 public void set_pubkey(byte[] val) {
34 bindings.RouteHop_set_pubkey(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
40 * The node_announcement features of the node at this hop. For the last hop, these may be
41 * amended to match the features present in the invoice this node generated.
43 public NodeFeatures get_node_features() {
44 long ret = bindings.RouteHop_get_node_features(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
48 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53 * The node_announcement features of the node at this hop. For the last hop, these may be
54 * amended to match the features present in the invoice this node generated.
56 public void set_node_features(org.ldk.structs.NodeFeatures val) {
57 bindings.RouteHop_set_node_features(this.ptr, val.ptr);
60 if (this != null) { this.ptrs_to.AddLast(val); };
64 * The channel that should be used from the previous hop to reach this node.
66 public long get_short_channel_id() {
67 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
73 * The channel that should be used from the previous hop to reach this node.
75 public void set_short_channel_id(long val) {
76 bindings.RouteHop_set_short_channel_id(this.ptr, val);
82 * The channel_announcement features of the channel that should be used from the previous hop
85 public ChannelFeatures get_channel_features() {
86 long ret = bindings.RouteHop_get_channel_features(this.ptr);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95 * The channel_announcement features of the channel that should be used from the previous hop
98 public void set_channel_features(org.ldk.structs.ChannelFeatures val) {
99 bindings.RouteHop_set_channel_features(this.ptr, val.ptr);
102 if (this != null) { this.ptrs_to.AddLast(val); };
106 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
107 * If this is the last hop in [`Path::hops`]:
108 * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
109 * otherwise, this is the full value of this [`Path`]'s part of the payment
111 * [`BlindedPath`]: crate::blinded_path::BlindedPath
113 public long get_fee_msat() {
114 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
120 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
121 * If this is the last hop in [`Path::hops`]:
122 * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
123 * otherwise, this is the full value of this [`Path`]'s part of the payment
125 * [`BlindedPath`]: crate::blinded_path::BlindedPath
127 public void set_fee_msat(long val) {
128 bindings.RouteHop_set_fee_msat(this.ptr, val);
134 * The CLTV delta added for this hop.
135 * If this is the last hop in [`Path::hops`]:
136 * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
137 * otherwise, this is the CLTV delta expected at the destination
139 * [`BlindedPath`]: crate::blinded_path::BlindedPath
141 public int get_cltv_expiry_delta() {
142 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
148 * The CLTV delta added for this hop.
149 * If this is the last hop in [`Path::hops`]:
150 * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
151 * otherwise, this is the CLTV delta expected at the destination
153 * [`BlindedPath`]: crate::blinded_path::BlindedPath
155 public void set_cltv_expiry_delta(int val) {
156 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
162 * Indicates whether this hop is possibly announced in the public network graph.
164 * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
165 * either know for sure it's announced in the public graph, or if any public channels exist
166 * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
167 * the channel to be unannounced.
169 * Will be `true` for objects serialized with LDK version 0.0.116 and before.
171 public bool get_maybe_announced_channel() {
172 bool ret = bindings.RouteHop_get_maybe_announced_channel(this.ptr);
178 * Indicates whether this hop is possibly announced in the public network graph.
180 * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
181 * either know for sure it's announced in the public graph, or if any public channels exist
182 * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
183 * the channel to be unannounced.
185 * Will be `true` for objects serialized with LDK version 0.0.116 and before.
187 public void set_maybe_announced_channel(bool val) {
188 bindings.RouteHop_set_maybe_announced_channel(this.ptr, val);
194 * Constructs a new RouteHop given each field
196 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, bool maybe_announced_channel_arg) {
197 long ret = bindings.RouteHop_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey_arg, 33)), node_features_arg.ptr, short_channel_id_arg, channel_features_arg.ptr, fee_msat_arg, cltv_expiry_delta_arg, maybe_announced_channel_arg);
198 GC.KeepAlive(pubkey_arg);
199 GC.KeepAlive(node_features_arg);
200 GC.KeepAlive(short_channel_id_arg);
201 GC.KeepAlive(channel_features_arg);
202 GC.KeepAlive(fee_msat_arg);
203 GC.KeepAlive(cltv_expiry_delta_arg);
204 GC.KeepAlive(maybe_announced_channel_arg);
205 if (ret >= 0 && ret <= 4096) { return null; }
206 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
207 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_features_arg); };
209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_features_arg); };
213 internal long clone_ptr() {
214 long ret = bindings.RouteHop_clone_ptr(this.ptr);
220 * Creates a copy of the RouteHop
222 public RouteHop clone() {
223 long ret = bindings.RouteHop_clone(this.ptr);
225 if (ret >= 0 && ret <= 4096) { return null; }
226 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
227 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
232 * Generates a non-cryptographic 64-bit hash of the RouteHop.
235 long ret = bindings.RouteHop_hash(this.ptr);
240 public override int GetHashCode() {
241 return (int)this.hash();
244 * Checks if two RouteHops contain equal inner contents.
245 * This ignores pointers and is_owned flags and looks at the values in fields.
246 * Two objects with NULL inner values will be considered "equal" here.
248 public bool eq(org.ldk.structs.RouteHop b) {
249 bool ret = bindings.RouteHop_eq(this.ptr, b.ptr);
252 if (this != null) { this.ptrs_to.AddLast(b); };
256 public override bool Equals(object o) {
257 if (!(o is RouteHop)) return false;
258 return this.eq((RouteHop)o);
261 * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
263 public byte[] write() {
264 long ret = bindings.RouteHop_write(this.ptr);
266 if (ret >= 0 && ret <= 4096) { return null; }
267 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
272 * Read a RouteHop from a byte array, created by RouteHop_write
274 public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
275 long ret = bindings.RouteHop_read(InternalUtils.encodeUint8Array(ser));
277 if (ret >= 0 && ret <= 4096) { return null; }
278 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);