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