9a47ac3ec583d159cec6295fff07462b185c4878
[ldk-java] / c_sharp / src / org / ldk / structs / RouteHintHop.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 channel descriptor for a hop along a payment path.
11  */
12 public class RouteHintHop : CommonBase {
13         internal RouteHintHop(object _dummy, long ptr) : base(ptr) { }
14         ~RouteHintHop() {
15                 if (ptr != 0) { bindings.RouteHintHop_free(ptr); }
16         }
17
18         /**
19          * The node_id of the non-target end of the route
20          */
21         public byte[] get_src_node_id() {
22                 long ret = bindings.RouteHintHop_get_src_node_id(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
26                 return ret_conv;
27         }
28
29         /**
30          * The node_id of the non-target end of the route
31          */
32         public void set_src_node_id(byte[] val) {
33                 bindings.RouteHintHop_set_src_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * The short_channel_id of this channel
40          */
41         public long get_short_channel_id() {
42                 long ret = bindings.RouteHintHop_get_short_channel_id(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * The short_channel_id of this channel
49          */
50         public void set_short_channel_id(long val) {
51                 bindings.RouteHintHop_set_short_channel_id(this.ptr, val);
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * The fees which must be paid to use this channel
58          */
59         public RoutingFees get_fees() {
60                 long ret = bindings.RouteHintHop_get_fees(this.ptr);
61                 GC.KeepAlive(this);
62                 if (ret >= 0 && ret <= 4096) { return null; }
63                 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
64                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
65                 return ret_hu_conv;
66         }
67
68         /**
69          * The fees which must be paid to use this channel
70          */
71         public void set_fees(org.ldk.structs.RoutingFees val) {
72                 bindings.RouteHintHop_set_fees(this.ptr, val == null ? 0 : val.ptr);
73                 GC.KeepAlive(this);
74                 GC.KeepAlive(val);
75                 if (this != null) { this.ptrs_to.AddLast(val); };
76         }
77
78         /**
79          * The difference in CLTV values between this node and the next node.
80          */
81         public short get_cltv_expiry_delta() {
82                 short ret = bindings.RouteHintHop_get_cltv_expiry_delta(this.ptr);
83                 GC.KeepAlive(this);
84                 return ret;
85         }
86
87         /**
88          * The difference in CLTV values between this node and the next node.
89          */
90         public void set_cltv_expiry_delta(short val) {
91                 bindings.RouteHintHop_set_cltv_expiry_delta(this.ptr, val);
92                 GC.KeepAlive(this);
93                 GC.KeepAlive(val);
94         }
95
96         /**
97          * The minimum value, in msat, which must be relayed to the next hop.
98          */
99         public Option_u64Z get_htlc_minimum_msat() {
100                 long ret = bindings.RouteHintHop_get_htlc_minimum_msat(this.ptr);
101                 GC.KeepAlive(this);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * The minimum value, in msat, which must be relayed to the next hop.
110          */
111         public void set_htlc_minimum_msat(org.ldk.structs.Option_u64Z val) {
112                 bindings.RouteHintHop_set_htlc_minimum_msat(this.ptr, val.ptr);
113                 GC.KeepAlive(this);
114                 GC.KeepAlive(val);
115                 if (this != null) { this.ptrs_to.AddLast(val); };
116         }
117
118         /**
119          * The maximum value in msat available for routing with a single HTLC.
120          */
121         public Option_u64Z get_htlc_maximum_msat() {
122                 long ret = bindings.RouteHintHop_get_htlc_maximum_msat(this.ptr);
123                 GC.KeepAlive(this);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * The maximum value in msat available for routing with a single HTLC.
132          */
133         public void set_htlc_maximum_msat(org.ldk.structs.Option_u64Z val) {
134                 bindings.RouteHintHop_set_htlc_maximum_msat(this.ptr, val.ptr);
135                 GC.KeepAlive(this);
136                 GC.KeepAlive(val);
137                 if (this != null) { this.ptrs_to.AddLast(val); };
138         }
139
140         /**
141          * Constructs a new RouteHintHop given each field
142          */
143         public static RouteHintHop of(byte[] src_node_id_arg, long short_channel_id_arg, org.ldk.structs.RoutingFees fees_arg, short cltv_expiry_delta_arg, org.ldk.structs.Option_u64Z htlc_minimum_msat_arg, org.ldk.structs.Option_u64Z htlc_maximum_msat_arg) {
144                 long ret = bindings.RouteHintHop_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(src_node_id_arg, 33)), short_channel_id_arg, fees_arg == null ? 0 : fees_arg.ptr, cltv_expiry_delta_arg, htlc_minimum_msat_arg.ptr, htlc_maximum_msat_arg.ptr);
145                 GC.KeepAlive(src_node_id_arg);
146                 GC.KeepAlive(short_channel_id_arg);
147                 GC.KeepAlive(fees_arg);
148                 GC.KeepAlive(cltv_expiry_delta_arg);
149                 GC.KeepAlive(htlc_minimum_msat_arg);
150                 GC.KeepAlive(htlc_maximum_msat_arg);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 org.ldk.structs.RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHintHop(null, ret); }
153                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fees_arg); };
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlc_minimum_msat_arg); };
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlc_maximum_msat_arg); };
157                 return ret_hu_conv;
158         }
159
160         internal long clone_ptr() {
161                 long ret = bindings.RouteHintHop_clone_ptr(this.ptr);
162                 GC.KeepAlive(this);
163                 return ret;
164         }
165
166         /**
167          * Creates a copy of the RouteHintHop
168          */
169         public RouteHintHop clone() {
170                 long ret = bindings.RouteHintHop_clone(this.ptr);
171                 GC.KeepAlive(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 org.ldk.structs.RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHintHop(null, ret); }
174                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
175                 return ret_hu_conv;
176         }
177
178         /**
179          * Generates a non-cryptographic 64-bit hash of the RouteHintHop.
180          */
181         public long hash() {
182                 long ret = bindings.RouteHintHop_hash(this.ptr);
183                 GC.KeepAlive(this);
184                 return ret;
185         }
186
187         public override int GetHashCode() {
188                 return (int)this.hash();
189         }
190         /**
191          * Checks if two RouteHintHops contain equal inner contents.
192          * This ignores pointers and is_owned flags and looks at the values in fields.
193          * Two objects with NULL inner values will be considered "equal" here.
194          */
195         public bool eq(org.ldk.structs.RouteHintHop b) {
196                 bool ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr);
197                 GC.KeepAlive(this);
198                 GC.KeepAlive(b);
199                 if (this != null) { this.ptrs_to.AddLast(b); };
200                 return ret;
201         }
202
203         public override bool Equals(object o) {
204                 if (!(o is RouteHintHop)) return false;
205                 return this.eq((RouteHintHop)o);
206         }
207         /**
208          * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
209          */
210         public byte[] write() {
211                 long ret = bindings.RouteHintHop_write(this.ptr);
212                 GC.KeepAlive(this);
213                 if (ret >= 0 && ret <= 4096) { return null; }
214                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
215                 return ret_conv;
216         }
217
218         /**
219          * Read a RouteHintHop from a byte array, created by RouteHintHop_write
220          */
221         public static Result_RouteHintHopDecodeErrorZ read(byte[] ser) {
222                 long ret = bindings.RouteHintHop_read(InternalUtils.encodeUint8Array(ser));
223                 GC.KeepAlive(ser);
224                 if (ret >= 0 && ret <= 4096) { return null; }
225                 Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
226                 return ret_hu_conv;
227         }
228
229 }
230 } } }