b0c832a809c5ce616d4f3abcc12f531512bc6930
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelUpdateInfo.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  * Details about one direction of a channel as received within a [`ChannelUpdate`].
11  */
12 public class ChannelUpdateInfo : CommonBase {
13         internal ChannelUpdateInfo(object _dummy, long ptr) : base(ptr) { }
14         ~ChannelUpdateInfo() {
15                 if (ptr != 0) { bindings.ChannelUpdateInfo_free(ptr); }
16         }
17
18         /**
19          * When the last update to the channel direction was issued.
20          * Value is opaque, as set in the announcement.
21          */
22         public int get_last_update() {
23                 int ret = bindings.ChannelUpdateInfo_get_last_update(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * When the last update to the channel direction was issued.
30          * Value is opaque, as set in the announcement.
31          */
32         public void set_last_update(int val) {
33                 bindings.ChannelUpdateInfo_set_last_update(this.ptr, val);
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * Whether the channel can be currently used for payments (in this one direction).
40          */
41         public bool get_enabled() {
42                 bool ret = bindings.ChannelUpdateInfo_get_enabled(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * Whether the channel can be currently used for payments (in this one direction).
49          */
50         public void set_enabled(bool val) {
51                 bindings.ChannelUpdateInfo_set_enabled(this.ptr, val);
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * The difference in CLTV values that you must have when routing through this channel.
58          */
59         public short get_cltv_expiry_delta() {
60                 short ret = bindings.ChannelUpdateInfo_get_cltv_expiry_delta(this.ptr);
61                 GC.KeepAlive(this);
62                 return ret;
63         }
64
65         /**
66          * The difference in CLTV values that you must have when routing through this channel.
67          */
68         public void set_cltv_expiry_delta(short val) {
69                 bindings.ChannelUpdateInfo_set_cltv_expiry_delta(this.ptr, val);
70                 GC.KeepAlive(this);
71                 GC.KeepAlive(val);
72         }
73
74         /**
75          * The minimum value, which must be relayed to the next hop via the channel
76          */
77         public long get_htlc_minimum_msat() {
78                 long ret = bindings.ChannelUpdateInfo_get_htlc_minimum_msat(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * The minimum value, which must be relayed to the next hop via the channel
85          */
86         public void set_htlc_minimum_msat(long val) {
87                 bindings.ChannelUpdateInfo_set_htlc_minimum_msat(this.ptr, val);
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(val);
90         }
91
92         /**
93          * The maximum value which may be relayed to the next hop via the channel.
94          */
95         public long get_htlc_maximum_msat() {
96                 long ret = bindings.ChannelUpdateInfo_get_htlc_maximum_msat(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         /**
102          * The maximum value which may be relayed to the next hop via the channel.
103          */
104         public void set_htlc_maximum_msat(long val) {
105                 bindings.ChannelUpdateInfo_set_htlc_maximum_msat(this.ptr, val);
106                 GC.KeepAlive(this);
107                 GC.KeepAlive(val);
108         }
109
110         /**
111          * Fees charged when the channel is used for routing
112          */
113         public RoutingFees get_fees() {
114                 long ret = bindings.ChannelUpdateInfo_get_fees(this.ptr);
115                 GC.KeepAlive(this);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Fees charged when the channel is used for routing
124          */
125         public void set_fees(org.ldk.structs.RoutingFees val) {
126                 bindings.ChannelUpdateInfo_set_fees(this.ptr, val == null ? 0 : val.ptr);
127                 GC.KeepAlive(this);
128                 GC.KeepAlive(val);
129                 if (this != null) { this.ptrs_to.AddLast(val); };
130         }
131
132         /**
133          * Most recent update for the channel received from the network
134          * Mostly redundant with the data we store in fields explicitly.
135          * Everything else is useful only for sending out for initial routing sync.
136          * Not stored if contains excess data to prevent DoS.
137          * 
138          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
139          */
140         public ChannelUpdate get_last_update_message() {
141                 long ret = bindings.ChannelUpdateInfo_get_last_update_message(this.ptr);
142                 GC.KeepAlive(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Most recent update for the channel received from the network
151          * Mostly redundant with the data we store in fields explicitly.
152          * Everything else is useful only for sending out for initial routing sync.
153          * Not stored if contains excess data to prevent DoS.
154          * 
155          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
156          */
157         public void set_last_update_message(org.ldk.structs.ChannelUpdate val) {
158                 bindings.ChannelUpdateInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr);
159                 GC.KeepAlive(this);
160                 GC.KeepAlive(val);
161                 if (this != null) { this.ptrs_to.AddLast(val); };
162         }
163
164         /**
165          * Constructs a new ChannelUpdateInfo given each field
166          */
167         public static ChannelUpdateInfo of(int last_update_arg, bool enabled_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, long htlc_maximum_msat_arg, org.ldk.structs.RoutingFees fees_arg, org.ldk.structs.ChannelUpdate last_update_message_arg) {
168                 long ret = bindings.ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg == null ? 0 : fees_arg.ptr, last_update_message_arg == null ? 0 : last_update_message_arg.ptr);
169                 GC.KeepAlive(last_update_arg);
170                 GC.KeepAlive(enabled_arg);
171                 GC.KeepAlive(cltv_expiry_delta_arg);
172                 GC.KeepAlive(htlc_minimum_msat_arg);
173                 GC.KeepAlive(htlc_maximum_msat_arg);
174                 GC.KeepAlive(fees_arg);
175                 GC.KeepAlive(last_update_message_arg);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
178                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
179                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fees_arg); };
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(last_update_message_arg); };
181                 return ret_hu_conv;
182         }
183
184         internal long clone_ptr() {
185                 long ret = bindings.ChannelUpdateInfo_clone_ptr(this.ptr);
186                 GC.KeepAlive(this);
187                 return ret;
188         }
189
190         /**
191          * Creates a copy of the ChannelUpdateInfo
192          */
193         public ChannelUpdateInfo clone() {
194                 long ret = bindings.ChannelUpdateInfo_clone(this.ptr);
195                 GC.KeepAlive(this);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Checks if two ChannelUpdateInfos contain equal inner contents.
204          * This ignores pointers and is_owned flags and looks at the values in fields.
205          * Two objects with NULL inner values will be considered "equal" here.
206          */
207         public bool eq(org.ldk.structs.ChannelUpdateInfo b) {
208                 bool ret = bindings.ChannelUpdateInfo_eq(this.ptr, b == null ? 0 : b.ptr);
209                 GC.KeepAlive(this);
210                 GC.KeepAlive(b);
211                 if (this != null) { this.ptrs_to.AddLast(b); };
212                 return ret;
213         }
214
215         public override bool Equals(object o) {
216                 if (!(o is ChannelUpdateInfo)) return false;
217                 return this.eq((ChannelUpdateInfo)o);
218         }
219         /**
220          * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read
221          */
222         public byte[] write() {
223                 byte[] ret = bindings.ChannelUpdateInfo_write(this.ptr);
224                 GC.KeepAlive(this);
225                 return ret;
226         }
227
228         /**
229          * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write
230          */
231         public static Result_ChannelUpdateInfoDecodeErrorZ read(byte[] ser) {
232                 long ret = bindings.ChannelUpdateInfo_read(ser);
233                 GC.KeepAlive(ser);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 Result_ChannelUpdateInfoDecodeErrorZ ret_hu_conv = Result_ChannelUpdateInfoDecodeErrorZ.constr_from_ptr(ret);
236                 return ret_hu_conv;
237         }
238
239 }
240 } } }