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