Update auto-updated Java files
[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                 NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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 & ~1);
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(val);
62         }
63
64         /**
65          * The channel that should be used from the previous hop to reach this node.
66          */
67         public long get_short_channel_id() {
68                 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
69                 Reference.reachabilityFence(this);
70                 return ret;
71         }
72
73         /**
74          * The channel that should be used from the previous hop to reach this node.
75          */
76         public void set_short_channel_id(long val) {
77                 bindings.RouteHop_set_short_channel_id(this.ptr, val);
78                 Reference.reachabilityFence(this);
79                 Reference.reachabilityFence(val);
80         }
81
82         /**
83          * The channel_announcement features of the channel that should be used from the previous hop
84          * to reach this node.
85          */
86         public ChannelFeatures get_channel_features() {
87                 long ret = bindings.RouteHop_get_channel_features(this.ptr);
88                 Reference.reachabilityFence(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
91                 ret_hu_conv.ptrs_to.add(this);
92                 return ret_hu_conv;
93         }
94
95         /**
96          * The channel_announcement features of the channel that should be used from the previous hop
97          * to reach this node.
98          */
99         public void set_channel_features(ChannelFeatures val) {
100                 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr & ~1);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
107          * For the last hop, this should be the full value of the payment (might be more than
108          * requested if we had to match htlc_minimum_msat).
109          */
110         public long get_fee_msat() {
111                 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
118          * For the last hop, this should be the full value of the payment (might be more than
119          * requested if we had to match htlc_minimum_msat).
120          */
121         public void set_fee_msat(long val) {
122                 bindings.RouteHop_set_fee_msat(this.ptr, val);
123                 Reference.reachabilityFence(this);
124                 Reference.reachabilityFence(val);
125         }
126
127         /**
128          * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
129          * expected at the destination, in excess of the current block height.
130          */
131         public int get_cltv_expiry_delta() {
132                 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
139          * expected at the destination, in excess of the current block height.
140          */
141         public void set_cltv_expiry_delta(int val) {
142                 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
143                 Reference.reachabilityFence(this);
144                 Reference.reachabilityFence(val);
145         }
146
147         /**
148          * Constructs a new RouteHop given each field
149          */
150         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) {
151                 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);
152                 Reference.reachabilityFence(pubkey_arg);
153                 Reference.reachabilityFence(node_features_arg);
154                 Reference.reachabilityFence(short_channel_id_arg);
155                 Reference.reachabilityFence(channel_features_arg);
156                 Reference.reachabilityFence(fee_msat_arg);
157                 Reference.reachabilityFence(cltv_expiry_delta_arg);
158                 if (ret >= 0 && ret <= 4096) { return null; }
159                 RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHop(null, ret); }
160                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
161                 return ret_hu_conv;
162         }
163
164         long clone_ptr() {
165                 long ret = bindings.RouteHop_clone_ptr(this.ptr);
166                 Reference.reachabilityFence(this);
167                 return ret;
168         }
169
170         /**
171          * Creates a copy of the RouteHop
172          */
173         public RouteHop clone() {
174                 long ret = bindings.RouteHop_clone(this.ptr);
175                 Reference.reachabilityFence(this);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHop(null, ret); }
178                 ret_hu_conv.ptrs_to.add(this);
179                 return ret_hu_conv;
180         }
181
182         /**
183          * Checks if two RouteHops contain equal inner contents.
184          */
185         public long hash() {
186                 long ret = bindings.RouteHop_hash(this.ptr);
187                 Reference.reachabilityFence(this);
188                 return ret;
189         }
190
191         @Override public int hashCode() {
192                 return (int)this.hash();
193         }
194         /**
195          * Checks if two RouteHops contain equal inner contents.
196          * This ignores pointers and is_owned flags and looks at the values in fields.
197          * Two objects with NULL inner values will be considered "equal" here.
198          */
199         public boolean eq(RouteHop b) {
200                 boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
201                 Reference.reachabilityFence(this);
202                 Reference.reachabilityFence(b);
203                 this.ptrs_to.add(b);
204                 return ret;
205         }
206
207         @Override public boolean equals(Object o) {
208                 if (!(o instanceof RouteHop)) return false;
209                 return this.eq((RouteHop)o);
210         }
211         /**
212          * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
213          */
214         public byte[] write() {
215                 byte[] ret = bindings.RouteHop_write(this.ptr);
216                 Reference.reachabilityFence(this);
217                 return ret;
218         }
219
220         /**
221          * Read a RouteHop from a byte array, created by RouteHop_write
222          */
223         public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
224                 long ret = bindings.RouteHop_read(ser);
225                 Reference.reachabilityFence(ser);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
228                 return ret_hu_conv;
229         }
230
231 }