1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class RouteHop extends CommonBase {
14 RouteHop(Object _dummy, long ptr) { super(ptr); }
15 @Override @SuppressWarnings("deprecation")
16 protected void finalize() throws Throwable {
18 if (ptr != 0) { bindings.RouteHop_free(ptr); }
22 * The node_id of the node at this hop.
24 public byte[] get_pubkey() {
25 byte[] ret = bindings.RouteHop_get_pubkey(this.ptr);
30 * The node_id of the node at this hop.
32 public void set_pubkey(byte[] val) {
33 bindings.RouteHop_set_pubkey(this.ptr, val);
37 * The node_announcement features of the node at this hop. For the last hop, these may be
38 * amended to match the features present in the invoice this node generated.
40 public NodeFeatures get_node_features() {
41 long ret = bindings.RouteHop_get_node_features(this.ptr);
42 if (ret < 1024) { return null; }
43 NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
44 ret_hu_conv.ptrs_to.add(this);
49 * The node_announcement features of the node at this hop. For the last hop, these may be
50 * amended to match the features present in the invoice this node generated.
52 public void set_node_features(NodeFeatures val) {
53 bindings.RouteHop_set_node_features(this.ptr, val == null ? 0 : val.ptr & ~1);
54 this.ptrs_to.add(val);
58 * The channel that should be used from the previous hop to reach this node.
60 public long get_short_channel_id() {
61 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
66 * The channel that should be used from the previous hop to reach this node.
68 public void set_short_channel_id(long val) {
69 bindings.RouteHop_set_short_channel_id(this.ptr, val);
73 * The channel_announcement features of the channel that should be used from the previous hop
76 public ChannelFeatures get_channel_features() {
77 long ret = bindings.RouteHop_get_channel_features(this.ptr);
78 if (ret < 1024) { return null; }
79 ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
80 ret_hu_conv.ptrs_to.add(this);
85 * The channel_announcement features of the channel that should be used from the previous hop
88 public void set_channel_features(ChannelFeatures val) {
89 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr & ~1);
90 this.ptrs_to.add(val);
94 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
95 * For the last hop, this should be the full value of the payment (might be more than
96 * requested if we had to match htlc_minimum_msat).
98 public long get_fee_msat() {
99 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
104 * The fee taken on this hop (for paying for the use of the *next* channel in the path).
105 * For the last hop, this should be the full value of the payment (might be more than
106 * requested if we had to match htlc_minimum_msat).
108 public void set_fee_msat(long val) {
109 bindings.RouteHop_set_fee_msat(this.ptr, val);
113 * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
114 * expected at the destination, in excess of the current block height.
116 public int get_cltv_expiry_delta() {
117 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
122 * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
123 * expected at the destination, in excess of the current block height.
125 public void set_cltv_expiry_delta(int val) {
126 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
130 * Constructs a new RouteHop given each field
132 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) {
133 long ret = bindings.RouteHop_new(pubkey_arg, node_features_arg == null ? 0 : node_features_arg.ptr & ~1, short_channel_id_arg, channel_features_arg == null ? 0 : channel_features_arg.ptr & ~1, fee_msat_arg, cltv_expiry_delta_arg);
134 if (ret < 1024) { return null; }
135 RouteHop ret_hu_conv = new RouteHop(null, ret);
136 ret_hu_conv.ptrs_to.add(ret_hu_conv);
137 ret_hu_conv.ptrs_to.add(node_features_arg);
138 ret_hu_conv.ptrs_to.add(channel_features_arg);
143 * Creates a copy of the RouteHop
145 public RouteHop clone() {
146 long ret = bindings.RouteHop_clone(this.ptr);
147 if (ret < 1024) { return null; }
148 RouteHop ret_hu_conv = new RouteHop(null, ret);
149 ret_hu_conv.ptrs_to.add(this);
154 * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
156 public byte[] write() {
157 byte[] ret = bindings.RouteHop_write(this.ptr);
162 * Read a RouteHop from a byte array, created by RouteHop_write
164 public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
165 long ret = bindings.RouteHop_read(ser);
166 if (ret < 1024) { return null; }
167 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);