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