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