[C#] Run tests against release library in determinism CI run
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelReestablish.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_reestablish`] message to be sent to or received from a peer.
11  * 
12  * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
13  */
14 public class ChannelReestablish : CommonBase {
15         internal ChannelReestablish(object _dummy, long ptr) : base(ptr) { }
16         ~ChannelReestablish() {
17                 if (ptr != 0) { bindings.ChannelReestablish_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public ChannelId get_channel_id() {
24                 long ret = bindings.ChannelReestablish_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The channel ID
34          */
35         public void set_channel_id(org.ldk.structs.ChannelId val) {
36                 bindings.ChannelReestablish_set_channel_id(this.ptr, val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The next commitment number for the sender
44          */
45         public long get_next_local_commitment_number() {
46                 long ret = bindings.ChannelReestablish_get_next_local_commitment_number(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * The next commitment number for the sender
53          */
54         public void set_next_local_commitment_number(long val) {
55                 bindings.ChannelReestablish_set_next_local_commitment_number(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The next commitment number for the recipient
62          */
63         public long get_next_remote_commitment_number() {
64                 long ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this.ptr);
65                 GC.KeepAlive(this);
66                 return ret;
67         }
68
69         /**
70          * The next commitment number for the recipient
71          */
72         public void set_next_remote_commitment_number(long val) {
73                 bindings.ChannelReestablish_set_next_remote_commitment_number(this.ptr, val);
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
80          * belonging to the recipient
81          */
82         public byte[] get_your_last_per_commitment_secret() {
83                 long ret = bindings.ChannelReestablish_get_your_last_per_commitment_secret(this.ptr);
84                 GC.KeepAlive(this);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
87                 return ret_conv;
88         }
89
90         /**
91          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
92          * belonging to the recipient
93          */
94         public void set_your_last_per_commitment_secret(byte[] val) {
95                 bindings.ChannelReestablish_set_your_last_per_commitment_secret(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(val);
98         }
99
100         /**
101          * The sender's per-commitment point for their current commitment transaction
102          */
103         public byte[] get_my_current_per_commitment_point() {
104                 long ret = bindings.ChannelReestablish_get_my_current_per_commitment_point(this.ptr);
105                 GC.KeepAlive(this);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
108                 return ret_conv;
109         }
110
111         /**
112          * The sender's per-commitment point for their current commitment transaction
113          */
114         public void set_my_current_per_commitment_point(byte[] val) {
115                 bindings.ChannelReestablish_set_my_current_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
116                 GC.KeepAlive(this);
117                 GC.KeepAlive(val);
118         }
119
120         /**
121          * The next funding transaction ID
122          */
123         public Option_ThirtyTwoBytesZ get_next_funding_txid() {
124                 long ret = bindings.ChannelReestablish_get_next_funding_txid(this.ptr);
125                 GC.KeepAlive(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * The next funding transaction ID
134          */
135         public void set_next_funding_txid(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
136                 bindings.ChannelReestablish_set_next_funding_txid(this.ptr, val.ptr);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(val);
139                 if (this != null) { this.ptrs_to.AddLast(val); };
140         }
141
142         /**
143          * Constructs a new ChannelReestablish given each field
144          */
145         public static ChannelReestablish of(org.ldk.structs.ChannelId channel_id_arg, long next_local_commitment_number_arg, long next_remote_commitment_number_arg, byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg, org.ldk.structs.Option_ThirtyTwoBytesZ next_funding_txid_arg) {
146                 long ret = bindings.ChannelReestablish_new(channel_id_arg.ptr, next_local_commitment_number_arg, next_remote_commitment_number_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(your_last_per_commitment_secret_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(my_current_per_commitment_point_arg, 33)), next_funding_txid_arg.ptr);
147                 GC.KeepAlive(channel_id_arg);
148                 GC.KeepAlive(next_local_commitment_number_arg);
149                 GC.KeepAlive(next_remote_commitment_number_arg);
150                 GC.KeepAlive(your_last_per_commitment_secret_arg);
151                 GC.KeepAlive(my_current_per_commitment_point_arg);
152                 GC.KeepAlive(next_funding_txid_arg);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(next_funding_txid_arg); };
158                 return ret_hu_conv;
159         }
160
161         internal long clone_ptr() {
162                 long ret = bindings.ChannelReestablish_clone_ptr(this.ptr);
163                 GC.KeepAlive(this);
164                 return ret;
165         }
166
167         /**
168          * Creates a copy of the ChannelReestablish
169          */
170         public ChannelReestablish clone() {
171                 long ret = bindings.ChannelReestablish_clone(this.ptr);
172                 GC.KeepAlive(this);
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
175                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
176                 return ret_hu_conv;
177         }
178
179         /**
180          * Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
181          */
182         public long hash() {
183                 long ret = bindings.ChannelReestablish_hash(this.ptr);
184                 GC.KeepAlive(this);
185                 return ret;
186         }
187
188         public override int GetHashCode() {
189                 return (int)this.hash();
190         }
191         /**
192          * Checks if two ChannelReestablishs contain equal inner contents.
193          * This ignores pointers and is_owned flags and looks at the values in fields.
194          * Two objects with NULL inner values will be considered "equal" here.
195          */
196         public bool eq(org.ldk.structs.ChannelReestablish b) {
197                 bool ret = bindings.ChannelReestablish_eq(this.ptr, b.ptr);
198                 GC.KeepAlive(this);
199                 GC.KeepAlive(b);
200                 if (this != null) { this.ptrs_to.AddLast(b); };
201                 return ret;
202         }
203
204         public override bool Equals(object o) {
205                 if (!(o is ChannelReestablish)) return false;
206                 return this.eq((ChannelReestablish)o);
207         }
208         /**
209          * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
210          */
211         public byte[] write() {
212                 long ret = bindings.ChannelReestablish_write(this.ptr);
213                 GC.KeepAlive(this);
214                 if (ret >= 0 && ret <= 4096) { return null; }
215                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
216                 return ret_conv;
217         }
218
219         /**
220          * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
221          */
222         public static Result_ChannelReestablishDecodeErrorZ read(byte[] ser) {
223                 long ret = bindings.ChannelReestablish_read(InternalUtils.encodeUint8Array(ser));
224                 GC.KeepAlive(ser);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);
227                 return ret_hu_conv;
228         }
229
230 }
231 } } }