Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / RouteHop.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * A hop in a route
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class RouteHop extends CommonBase {
15         RouteHop(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.RouteHop_free(ptr); }
20         }
21
22         /**
23          * The node_id of the node at this hop.
24          */
25         public byte[] get_pubkey() {
26                 byte[] ret = bindings.RouteHop_get_pubkey(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * The node_id of the node at this hop.
32          */
33         public void set_pubkey(byte[] val) {
34                 bindings.RouteHop_set_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
35         }
36
37         /**
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.
40          */
41         public NodeFeatures get_node_features() {
42                 long ret = bindings.RouteHop_get_node_features(this.ptr);
43                 if (ret >= 0 && ret <= 4096) { return null; }
44                 NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
45                 ret_hu_conv.ptrs_to.add(this);
46                 return ret_hu_conv;
47         }
48
49         /**
50          * The node_announcement features of the node at this hop. For the last hop, these may be
51          * amended to match the features present in the invoice this node generated.
52          */
53         public void set_node_features(NodeFeatures val) {
54                 bindings.RouteHop_set_node_features(this.ptr, val == null ? 0 : val.ptr & ~1);
55         }
56
57         /**
58          * The channel that should be used from the previous hop to reach this node.
59          */
60         public long get_short_channel_id() {
61                 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
62                 return ret;
63         }
64
65         /**
66          * The channel that should be used from the previous hop to reach this node.
67          */
68         public void set_short_channel_id(long val) {
69                 bindings.RouteHop_set_short_channel_id(this.ptr, val);
70         }
71
72         /**
73          * The channel_announcement features of the channel that should be used from the previous hop
74          * to reach this node.
75          */
76         public ChannelFeatures get_channel_features() {
77                 long ret = bindings.RouteHop_get_channel_features(this.ptr);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
80                 ret_hu_conv.ptrs_to.add(this);
81                 return ret_hu_conv;
82         }
83
84         /**
85          * The channel_announcement features of the channel that should be used from the previous hop
86          * to reach this node.
87          */
88         public void set_channel_features(ChannelFeatures val) {
89                 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr & ~1);
90         }
91
92         /**
93          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
94          * For the last hop, this should be the full value of the payment (might be more than
95          * requested if we had to match htlc_minimum_msat).
96          */
97         public long get_fee_msat() {
98                 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
99                 return ret;
100         }
101
102         /**
103          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
104          * For the last hop, this should be the full value of the payment (might be more than
105          * requested if we had to match htlc_minimum_msat).
106          */
107         public void set_fee_msat(long val) {
108                 bindings.RouteHop_set_fee_msat(this.ptr, val);
109         }
110
111         /**
112          * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
113          * expected at the destination, in excess of the current block height.
114          */
115         public int get_cltv_expiry_delta() {
116                 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
117                 return ret;
118         }
119
120         /**
121          * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
122          * expected at the destination, in excess of the current block height.
123          */
124         public void set_cltv_expiry_delta(int val) {
125                 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
126         }
127
128         /**
129          * Constructs a new RouteHop given each field
130          */
131         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) {
132                 long ret = bindings.RouteHop_new(InternalUtils.check_arr_len(pubkey_arg, 33), 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);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHop(null, ret); }
135                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
136                 return ret_hu_conv;
137         }
138
139         long clone_ptr() {
140                 long ret = bindings.RouteHop_clone_ptr(this.ptr);
141                 return ret;
142         }
143
144         /**
145          * Creates a copy of the RouteHop
146          */
147         public RouteHop clone() {
148                 long ret = bindings.RouteHop_clone(this.ptr);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHop(null, ret); }
151                 ret_hu_conv.ptrs_to.add(this);
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Checks if two RouteHops contain equal inner contents.
157          */
158         public long hash() {
159                 long ret = bindings.RouteHop_hash(this.ptr);
160                 return ret;
161         }
162
163         /**
164          * Checks if two RouteHops contain equal inner contents.
165          * This ignores pointers and is_owned flags and looks at the values in fields.
166          * Two objects with NULL inner values will be considered "equal" here.
167          */
168         public boolean eq(RouteHop b) {
169                 boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
170                 this.ptrs_to.add(b);
171                 return ret;
172         }
173
174         /**
175          * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
176          */
177         public byte[] write() {
178                 byte[] ret = bindings.RouteHop_write(this.ptr);
179                 return ret;
180         }
181
182         /**
183          * Read a RouteHop from a byte array, created by RouteHop_write
184          */
185         public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
186                 long ret = bindings.RouteHop_read(ser);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
189                 return ret_hu_conv;
190         }
191
192 }