Update auto-generated bindings to latest upstream
[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, val);
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 < 1024) { return null; }
44                 NodeFeatures 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                 this.ptrs_to.add(val);
56         }
57
58         /**
59          * The channel that should be used from the previous hop to reach this node.
60          */
61         public long get_short_channel_id() {
62                 long ret = bindings.RouteHop_get_short_channel_id(this.ptr);
63                 return ret;
64         }
65
66         /**
67          * The channel that should be used from the previous hop to reach this node.
68          */
69         public void set_short_channel_id(long val) {
70                 bindings.RouteHop_set_short_channel_id(this.ptr, val);
71         }
72
73         /**
74          * The channel_announcement features of the channel that should be used from the previous hop
75          * to reach this node.
76          */
77         public ChannelFeatures get_channel_features() {
78                 long ret = bindings.RouteHop_get_channel_features(this.ptr);
79                 if (ret < 1024) { return null; }
80                 ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
81                 ret_hu_conv.ptrs_to.add(this);
82                 return ret_hu_conv;
83         }
84
85         /**
86          * The channel_announcement features of the channel that should be used from the previous hop
87          * to reach this node.
88          */
89         public void set_channel_features(ChannelFeatures val) {
90                 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr & ~1);
91                 this.ptrs_to.add(val);
92         }
93
94         /**
95          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
96          * For the last hop, this should be the full value of the payment (might be more than
97          * requested if we had to match htlc_minimum_msat).
98          */
99         public long get_fee_msat() {
100                 long ret = bindings.RouteHop_get_fee_msat(this.ptr);
101                 return ret;
102         }
103
104         /**
105          * The fee taken on this hop (for paying for the use of the *next* channel in the path).
106          * For the last hop, this should be the full value of the payment (might be more than
107          * requested if we had to match htlc_minimum_msat).
108          */
109         public void set_fee_msat(long val) {
110                 bindings.RouteHop_set_fee_msat(this.ptr, val);
111         }
112
113         /**
114          * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
115          * expected at the destination, in excess of the current block height.
116          */
117         public int get_cltv_expiry_delta() {
118                 int ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
119                 return ret;
120         }
121
122         /**
123          * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value
124          * expected at the destination, in excess of the current block height.
125          */
126         public void set_cltv_expiry_delta(int val) {
127                 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
128         }
129
130         /**
131          * Constructs a new RouteHop given each field
132          */
133         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) {
134                 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);
135                 if (ret < 1024) { return null; }
136                 RouteHop ret_hu_conv = new RouteHop(null, ret);
137                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
138                 ret_hu_conv.ptrs_to.add(node_features_arg);
139                 ret_hu_conv.ptrs_to.add(channel_features_arg);
140                 return ret_hu_conv;
141         }
142
143         /**
144          * Creates a copy of the RouteHop
145          */
146         public RouteHop clone() {
147                 long ret = bindings.RouteHop_clone(this.ptr);
148                 if (ret < 1024) { return null; }
149                 RouteHop ret_hu_conv = new RouteHop(null, ret);
150                 ret_hu_conv.ptrs_to.add(this);
151                 return ret_hu_conv;
152         }
153
154         /**
155          * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
156          */
157         public byte[] write() {
158                 byte[] ret = bindings.RouteHop_write(this.ptr);
159                 return ret;
160         }
161
162         /**
163          * Read a RouteHop from a byte array, created by RouteHop_write
164          */
165         public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
166                 long ret = bindings.RouteHop_read(ser);
167                 if (ret < 1024) { return null; }
168                 Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
169                 return ret_hu_conv;
170         }
171
172 }