2dc601e5be56025987c9b86cd3140ea47874e23b
[ldk-java] / c_sharp / src / org / ldk / structs / UnsignedChannelUpdate.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  * The unsigned part of a channel_update
11  */
12 public class UnsignedChannelUpdate : CommonBase {
13         internal UnsignedChannelUpdate(object _dummy, long ptr) : base(ptr) { }
14         ~UnsignedChannelUpdate() {
15                 if (ptr != 0) { bindings.UnsignedChannelUpdate_free(ptr); }
16         }
17
18         /**
19          * The genesis hash of the blockchain where the channel is to be opened
20          */
21         public byte[] get_chain_hash() {
22                 byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * The genesis hash of the blockchain where the channel is to be opened
29          */
30         public void set_chain_hash(byte[] val) {
31                 bindings.UnsignedChannelUpdate_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * The short channel ID
38          */
39         public long get_short_channel_id() {
40                 long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this.ptr);
41                 GC.KeepAlive(this);
42                 return ret;
43         }
44
45         /**
46          * The short channel ID
47          */
48         public void set_short_channel_id(long val) {
49                 bindings.UnsignedChannelUpdate_set_short_channel_id(this.ptr, val);
50                 GC.KeepAlive(this);
51                 GC.KeepAlive(val);
52         }
53
54         /**
55          * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
56          */
57         public int get_timestamp() {
58                 int ret = bindings.UnsignedChannelUpdate_get_timestamp(this.ptr);
59                 GC.KeepAlive(this);
60                 return ret;
61         }
62
63         /**
64          * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
65          */
66         public void set_timestamp(int val) {
67                 bindings.UnsignedChannelUpdate_set_timestamp(this.ptr, val);
68                 GC.KeepAlive(this);
69                 GC.KeepAlive(val);
70         }
71
72         /**
73          * Channel flags
74          */
75         public byte get_flags() {
76                 byte ret = bindings.UnsignedChannelUpdate_get_flags(this.ptr);
77                 GC.KeepAlive(this);
78                 return ret;
79         }
80
81         /**
82          * Channel flags
83          */
84         public void set_flags(byte val) {
85                 bindings.UnsignedChannelUpdate_set_flags(this.ptr, val);
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(val);
88         }
89
90         /**
91          * The number of blocks such that if:
92          * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
93          * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
94          * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
95          * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
96          * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
97          * forwarding. Note that the HTLC sender is the one who originally sets this value when
98          * constructing the route.
99          */
100         public short get_cltv_expiry_delta() {
101                 short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this.ptr);
102                 GC.KeepAlive(this);
103                 return ret;
104         }
105
106         /**
107          * The number of blocks such that if:
108          * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
109          * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
110          * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
111          * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
112          * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
113          * forwarding. Note that the HTLC sender is the one who originally sets this value when
114          * constructing the route.
115          */
116         public void set_cltv_expiry_delta(short val) {
117                 bindings.UnsignedChannelUpdate_set_cltv_expiry_delta(this.ptr, val);
118                 GC.KeepAlive(this);
119                 GC.KeepAlive(val);
120         }
121
122         /**
123          * The minimum HTLC size incoming to sender, in milli-satoshi
124          */
125         public long get_htlc_minimum_msat() {
126                 long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this.ptr);
127                 GC.KeepAlive(this);
128                 return ret;
129         }
130
131         /**
132          * The minimum HTLC size incoming to sender, in milli-satoshi
133          */
134         public void set_htlc_minimum_msat(long val) {
135                 bindings.UnsignedChannelUpdate_set_htlc_minimum_msat(this.ptr, val);
136                 GC.KeepAlive(this);
137                 GC.KeepAlive(val);
138         }
139
140         /**
141          * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
142          */
143         public long get_htlc_maximum_msat() {
144                 long ret = bindings.UnsignedChannelUpdate_get_htlc_maximum_msat(this.ptr);
145                 GC.KeepAlive(this);
146                 return ret;
147         }
148
149         /**
150          * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
151          */
152         public void set_htlc_maximum_msat(long val) {
153                 bindings.UnsignedChannelUpdate_set_htlc_maximum_msat(this.ptr, val);
154                 GC.KeepAlive(this);
155                 GC.KeepAlive(val);
156         }
157
158         /**
159          * The base HTLC fee charged by sender, in milli-satoshi
160          */
161         public int get_fee_base_msat() {
162                 int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this.ptr);
163                 GC.KeepAlive(this);
164                 return ret;
165         }
166
167         /**
168          * The base HTLC fee charged by sender, in milli-satoshi
169          */
170         public void set_fee_base_msat(int val) {
171                 bindings.UnsignedChannelUpdate_set_fee_base_msat(this.ptr, val);
172                 GC.KeepAlive(this);
173                 GC.KeepAlive(val);
174         }
175
176         /**
177          * The amount to fee multiplier, in micro-satoshi
178          */
179         public int get_fee_proportional_millionths() {
180                 int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this.ptr);
181                 GC.KeepAlive(this);
182                 return ret;
183         }
184
185         /**
186          * The amount to fee multiplier, in micro-satoshi
187          */
188         public void set_fee_proportional_millionths(int val) {
189                 bindings.UnsignedChannelUpdate_set_fee_proportional_millionths(this.ptr, val);
190                 GC.KeepAlive(this);
191                 GC.KeepAlive(val);
192         }
193
194         /**
195          * Excess data which was signed as a part of the message which we do not (yet) understand how
196          * to decode. This is stored to ensure forward-compatibility as new fields are added to the
197          * lightning gossip
198          * 
199          * Returns a copy of the field.
200          */
201         public byte[] get_excess_data() {
202                 byte[] ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr);
203                 GC.KeepAlive(this);
204                 return ret;
205         }
206
207         /**
208          * Excess data which was signed as a part of the message which we do not (yet) understand how
209          * to decode. This is stored to ensure forward-compatibility as new fields are added to the
210          * lightning gossip
211          */
212         public void set_excess_data(byte[] val) {
213                 bindings.UnsignedChannelUpdate_set_excess_data(this.ptr, val);
214                 GC.KeepAlive(this);
215                 GC.KeepAlive(val);
216         }
217
218         /**
219          * Constructs a new UnsignedChannelUpdate given each field
220          */
221         public static UnsignedChannelUpdate of(byte[] chain_hash_arg, long short_channel_id_arg, int timestamp_arg, byte flags_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, long htlc_maximum_msat_arg, int fee_base_msat_arg, int fee_proportional_millionths_arg, byte[] excess_data_arg) {
222                 long ret = bindings.UnsignedChannelUpdate_new(InternalUtils.check_arr_len(chain_hash_arg, 32), short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg);
223                 GC.KeepAlive(chain_hash_arg);
224                 GC.KeepAlive(short_channel_id_arg);
225                 GC.KeepAlive(timestamp_arg);
226                 GC.KeepAlive(flags_arg);
227                 GC.KeepAlive(cltv_expiry_delta_arg);
228                 GC.KeepAlive(htlc_minimum_msat_arg);
229                 GC.KeepAlive(htlc_maximum_msat_arg);
230                 GC.KeepAlive(fee_base_msat_arg);
231                 GC.KeepAlive(fee_proportional_millionths_arg);
232                 GC.KeepAlive(excess_data_arg);
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
236                 return ret_hu_conv;
237         }
238
239         internal long clone_ptr() {
240                 long ret = bindings.UnsignedChannelUpdate_clone_ptr(this.ptr);
241                 GC.KeepAlive(this);
242                 return ret;
243         }
244
245         /**
246          * Creates a copy of the UnsignedChannelUpdate
247          */
248         public UnsignedChannelUpdate clone() {
249                 long ret = bindings.UnsignedChannelUpdate_clone(this.ptr);
250                 GC.KeepAlive(this);
251                 if (ret >= 0 && ret <= 4096) { return null; }
252                 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
253                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
254                 return ret_hu_conv;
255         }
256
257         /**
258          * Checks if two UnsignedChannelUpdates contain equal inner contents.
259          * This ignores pointers and is_owned flags and looks at the values in fields.
260          * Two objects with NULL inner values will be considered "equal" here.
261          */
262         public bool eq(org.ldk.structs.UnsignedChannelUpdate b) {
263                 bool ret = bindings.UnsignedChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
264                 GC.KeepAlive(this);
265                 GC.KeepAlive(b);
266                 if (this != null) { this.ptrs_to.AddLast(b); };
267                 return ret;
268         }
269
270         public override bool Equals(object o) {
271                 if (!(o is UnsignedChannelUpdate)) return false;
272                 return this.eq((UnsignedChannelUpdate)o);
273         }
274         /**
275          * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
276          */
277         public byte[] write() {
278                 byte[] ret = bindings.UnsignedChannelUpdate_write(this.ptr);
279                 GC.KeepAlive(this);
280                 return ret;
281         }
282
283         /**
284          * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
285          */
286         public static Result_UnsignedChannelUpdateDecodeErrorZ read(byte[] ser) {
287                 long ret = bindings.UnsignedChannelUpdate_read(ser);
288                 GC.KeepAlive(ser);
289                 if (ret >= 0 && ret <= 4096) { return null; }
290                 Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
291                 return ret_hu_conv;
292         }
293
294 }
295 } } }