9218cd62779c0bffe66bd6fa1f0be147204621b6
[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 byte[] get_channel_id() {
24                 byte[] ret = bindings.ChannelReestablish_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * The channel ID
31          */
32         public void set_channel_id(byte[] val) {
33                 bindings.ChannelReestablish_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * The next commitment number for the sender
40          */
41         public long get_next_local_commitment_number() {
42                 long ret = bindings.ChannelReestablish_get_next_local_commitment_number(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * The next commitment number for the sender
49          */
50         public void set_next_local_commitment_number(long val) {
51                 bindings.ChannelReestablish_set_next_local_commitment_number(this.ptr, val);
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * The next commitment number for the recipient
58          */
59         public long get_next_remote_commitment_number() {
60                 long ret = bindings.ChannelReestablish_get_next_remote_commitment_number(this.ptr);
61                 GC.KeepAlive(this);
62                 return ret;
63         }
64
65         /**
66          * The next commitment number for the recipient
67          */
68         public void set_next_remote_commitment_number(long val) {
69                 bindings.ChannelReestablish_set_next_remote_commitment_number(this.ptr, val);
70                 GC.KeepAlive(this);
71                 GC.KeepAlive(val);
72         }
73
74         /**
75          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
76          * belonging to the recipient
77          */
78         public byte[] get_your_last_per_commitment_secret() {
79                 byte[] ret = bindings.ChannelReestablish_get_your_last_per_commitment_secret(this.ptr);
80                 GC.KeepAlive(this);
81                 return ret;
82         }
83
84         /**
85          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
86          * belonging to the recipient
87          */
88         public void set_your_last_per_commitment_secret(byte[] val) {
89                 bindings.ChannelReestablish_set_your_last_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
90                 GC.KeepAlive(this);
91                 GC.KeepAlive(val);
92         }
93
94         /**
95          * The sender's per-commitment point for their current commitment transaction
96          */
97         public byte[] get_my_current_per_commitment_point() {
98                 byte[] ret = bindings.ChannelReestablish_get_my_current_per_commitment_point(this.ptr);
99                 GC.KeepAlive(this);
100                 return ret;
101         }
102
103         /**
104          * The sender's per-commitment point for their current commitment transaction
105          */
106         public void set_my_current_per_commitment_point(byte[] val) {
107                 bindings.ChannelReestablish_set_my_current_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
108                 GC.KeepAlive(this);
109                 GC.KeepAlive(val);
110         }
111
112         /**
113          * The next funding transaction ID
114          */
115         public Option_TxidZ get_next_funding_txid() {
116                 long ret = bindings.ChannelReestablish_get_next_funding_txid(this.ptr);
117                 GC.KeepAlive(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.Option_TxidZ ret_hu_conv = org.ldk.structs.Option_TxidZ.constr_from_ptr(ret);
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * The next funding transaction ID
126          */
127         public void set_next_funding_txid(org.ldk.structs.Option_TxidZ val) {
128                 bindings.ChannelReestablish_set_next_funding_txid(this.ptr, val.ptr);
129                 GC.KeepAlive(this);
130                 GC.KeepAlive(val);
131                 if (this != null) { this.ptrs_to.AddLast(val); };
132         }
133
134         /**
135          * Constructs a new ChannelReestablish given each field
136          */
137         public static ChannelReestablish of(byte[] 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_TxidZ next_funding_txid_arg) {
138                 long ret = bindings.ChannelReestablish_new(InternalUtils.check_arr_len(channel_id_arg, 32), next_local_commitment_number_arg, next_remote_commitment_number_arg, InternalUtils.check_arr_len(your_last_per_commitment_secret_arg, 32), InternalUtils.check_arr_len(my_current_per_commitment_point_arg, 33), next_funding_txid_arg.ptr);
139                 GC.KeepAlive(channel_id_arg);
140                 GC.KeepAlive(next_local_commitment_number_arg);
141                 GC.KeepAlive(next_remote_commitment_number_arg);
142                 GC.KeepAlive(your_last_per_commitment_secret_arg);
143                 GC.KeepAlive(my_current_per_commitment_point_arg);
144                 GC.KeepAlive(next_funding_txid_arg);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
148                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(next_funding_txid_arg); };
149                 return ret_hu_conv;
150         }
151
152         internal long clone_ptr() {
153                 long ret = bindings.ChannelReestablish_clone_ptr(this.ptr);
154                 GC.KeepAlive(this);
155                 return ret;
156         }
157
158         /**
159          * Creates a copy of the ChannelReestablish
160          */
161         public ChannelReestablish clone() {
162                 long ret = bindings.ChannelReestablish_clone(this.ptr);
163                 GC.KeepAlive(this);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 org.ldk.structs.ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReestablish(null, ret); }
166                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
167                 return ret_hu_conv;
168         }
169
170         /**
171          * Checks if two ChannelReestablishs contain equal inner contents.
172          * This ignores pointers and is_owned flags and looks at the values in fields.
173          * Two objects with NULL inner values will be considered "equal" here.
174          */
175         public bool eq(org.ldk.structs.ChannelReestablish b) {
176                 bool ret = bindings.ChannelReestablish_eq(this.ptr, b == null ? 0 : b.ptr);
177                 GC.KeepAlive(this);
178                 GC.KeepAlive(b);
179                 if (this != null) { this.ptrs_to.AddLast(b); };
180                 return ret;
181         }
182
183         public override bool Equals(object o) {
184                 if (!(o is ChannelReestablish)) return false;
185                 return this.eq((ChannelReestablish)o);
186         }
187         /**
188          * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
189          */
190         public byte[] write() {
191                 byte[] ret = bindings.ChannelReestablish_write(this.ptr);
192                 GC.KeepAlive(this);
193                 return ret;
194         }
195
196         /**
197          * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
198          */
199         public static Result_ChannelReestablishDecodeErrorZ read(byte[] ser) {
200                 long ret = bindings.ChannelReestablish_read(ser);
201                 GC.KeepAlive(ser);
202                 if (ret >= 0 && ret <= 4096) { return null; }
203                 Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);
204                 return ret_hu_conv;
205         }
206
207 }
208 } } }