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 byte[] ret = bindings.RouteHop_get_pubkey(this.ptr);
29 * The node_id of the node at this hop.
31 public void set_pubkey(byte[] val) {
32 bindings.RouteHop_set_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
38 * The node_announcement features of the node at this hop. For the last hop, these may be
39 * amended to match the features present in the invoice this node generated.
41 public NodeFeatures get_node_features() {
42 long ret = bindings.RouteHop_get_node_features(this.ptr);
44 if (ret >= 0 && ret <= 4096) { return null; }
45 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
46 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
51 * The node_announcement features of the node at this hop. For the last hop, these may be
52 * amended to match the features present in the invoice this node generated.
54 public void set_node_features(org.ldk.structs.NodeFeatures val) {
55 bindings.RouteHop_set_node_features(this.ptr, val == null ? 0 : val.ptr);
58 if (this != null) { this.ptrs_to.AddLast(val); };
62 * The channel that should be used from the previous hop to reach this node.
64 public long get_short_channel_id() {
65 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
71 * The channel that should be used from the previous hop to reach this node.
73 public void set_short_channel_id(long val) {
74 bindings.RouteHop_set_short_channel_id(this.ptr, val);
80 * The channel_announcement features of the channel that should be used from the previous hop
83 public ChannelFeatures get_channel_features() {
84 long ret = bindings.RouteHop_get_channel_features(this.ptr);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
88 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
93 * The channel_announcement features of the channel that should be used from the previous hop
96 public void set_channel_features(org.ldk.structs.ChannelFeatures val) {
97 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr);
100 if (this != null) { this.ptrs_to.AddLast(val); };
104 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
105 * If this is the last hop in [`Path::hops`]:
106 * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
107 * otherwise, this is the full value of this [`Path`]'s part of the payment
109 * [`BlindedPath`]: crate::blinded_path::BlindedPath
111 public long get_fee_msat() {
112 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
118 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
119 * If this is the last hop in [`Path::hops`]:
120 * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
121 * otherwise, this is the full value of this [`Path`]'s part of the payment
123 * [`BlindedPath`]: crate::blinded_path::BlindedPath
125 public void set_fee_msat(long val) {
126 bindings.RouteHop_set_fee_msat(this.ptr, val);
132 * The CLTV delta added for this hop.
133 * If this is the last hop in [`Path::hops`]:
134 * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
135 * otherwise, this is the CLTV delta expected at the destination
137 * [`BlindedPath`]: crate::blinded_path::BlindedPath
139 public int get_cltv_expiry_delta() {
140 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
146 * The CLTV delta added for this hop.
147 * If this is the last hop in [`Path::hops`]:
148 * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
149 * otherwise, this is the CLTV delta expected at the destination
151 * [`BlindedPath`]: crate::blinded_path::BlindedPath
153 public void set_cltv_expiry_delta(int val) {
154 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
160 * Constructs a new RouteHop given each field
162 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) {
163 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);
164 GC.KeepAlive(pubkey_arg);
165 GC.KeepAlive(node_features_arg);
166 GC.KeepAlive(short_channel_id_arg);
167 GC.KeepAlive(channel_features_arg);
168 GC.KeepAlive(fee_msat_arg);
169 GC.KeepAlive(cltv_expiry_delta_arg);
170 if (ret >= 0 && ret <= 4096) { return null; }
171 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
172 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
173 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_features_arg); };
174 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_features_arg); };
178 internal long clone_ptr() {
179 long ret = bindings.RouteHop_clone_ptr(this.ptr);
185 * Creates a copy of the RouteHop
187 public RouteHop clone() {
188 long ret = bindings.RouteHop_clone(this.ptr);
190 if (ret >= 0 && ret <= 4096) { return null; }
191 org.ldk.structs.RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHop(null, ret); }
192 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
197 * Generates a non-cryptographic 64-bit hash of the RouteHop.
200 long ret = bindings.RouteHop_hash(this.ptr);
205 public override int GetHashCode() {
206 return (int)this.hash();
209 * Checks if two RouteHops contain equal inner contents.
210 * This ignores pointers and is_owned flags and looks at the values in fields.
211 * Two objects with NULL inner values will be considered "equal" here.
213 public bool eq(org.ldk.structs.RouteHop b) {
214 bool ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr);
217 if (this != null) { this.ptrs_to.AddLast(b); };
221 public override bool Equals(object o) {
222 if (!(o is RouteHop)) return false;
223 return this.eq((RouteHop)o);
226 * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
228 public byte[] write() {
229 byte[] ret = bindings.RouteHop_write(this.ptr);
235 * Read a RouteHop from a byte array, created by RouteHop_write
237 public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
238 long ret = bindings.RouteHop_read(ser);
240 if (ret >= 0 && ret <= 4096) { return null; }
241 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);