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