[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelMessageHandler.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of ChannelMessageHandler */
12 public interface ChannelMessageHandlerInterface {
13         /**Handle an incoming `open_channel` message from the given peer.
14          */
15         void handle_open_channel(byte[] their_node_id, OpenChannel msg);
16         /**Handle an incoming `open_channel2` message from the given peer.
17          */
18         void handle_open_channel_v2(byte[] their_node_id, OpenChannelV2 msg);
19         /**Handle an incoming `accept_channel` message from the given peer.
20          */
21         void handle_accept_channel(byte[] their_node_id, AcceptChannel msg);
22         /**Handle an incoming `accept_channel2` message from the given peer.
23          */
24         void handle_accept_channel_v2(byte[] their_node_id, AcceptChannelV2 msg);
25         /**Handle an incoming `funding_created` message from the given peer.
26          */
27         void handle_funding_created(byte[] their_node_id, FundingCreated msg);
28         /**Handle an incoming `funding_signed` message from the given peer.
29          */
30         void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
31         /**Handle an incoming `channel_ready` message from the given peer.
32          */
33         void handle_channel_ready(byte[] their_node_id, ChannelReady msg);
34         /**Handle an incoming `shutdown` message from the given peer.
35          */
36         void handle_shutdown(byte[] their_node_id, Shutdown msg);
37         /**Handle an incoming `closing_signed` message from the given peer.
38          */
39         void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
40         /**Handle an incoming `stfu` message from the given peer.
41          */
42         void handle_stfu(byte[] their_node_id, Stfu msg);
43         /**Handle an incoming `tx_add_input message` from the given peer.
44          */
45         void handle_tx_add_input(byte[] their_node_id, TxAddInput msg);
46         /**Handle an incoming `tx_add_output` message from the given peer.
47          */
48         void handle_tx_add_output(byte[] their_node_id, TxAddOutput msg);
49         /**Handle an incoming `tx_remove_input` message from the given peer.
50          */
51         void handle_tx_remove_input(byte[] their_node_id, TxRemoveInput msg);
52         /**Handle an incoming `tx_remove_output` message from the given peer.
53          */
54         void handle_tx_remove_output(byte[] their_node_id, TxRemoveOutput msg);
55         /**Handle an incoming `tx_complete message` from the given peer.
56          */
57         void handle_tx_complete(byte[] their_node_id, TxComplete msg);
58         /**Handle an incoming `tx_signatures` message from the given peer.
59          */
60         void handle_tx_signatures(byte[] their_node_id, TxSignatures msg);
61         /**Handle an incoming `tx_init_rbf` message from the given peer.
62          */
63         void handle_tx_init_rbf(byte[] their_node_id, TxInitRbf msg);
64         /**Handle an incoming `tx_ack_rbf` message from the given peer.
65          */
66         void handle_tx_ack_rbf(byte[] their_node_id, TxAckRbf msg);
67         /**Handle an incoming `tx_abort message` from the given peer.
68          */
69         void handle_tx_abort(byte[] their_node_id, TxAbort msg);
70         /**Handle an incoming `update_add_htlc` message from the given peer.
71          */
72         void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
73         /**Handle an incoming `update_fulfill_htlc` message from the given peer.
74          */
75         void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
76         /**Handle an incoming `update_fail_htlc` message from the given peer.
77          */
78         void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
79         /**Handle an incoming `update_fail_malformed_htlc` message from the given peer.
80          */
81         void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
82         /**Handle an incoming `commitment_signed` message from the given peer.
83          */
84         void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
85         /**Handle an incoming `revoke_and_ack` message from the given peer.
86          */
87         void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
88         /**Handle an incoming `update_fee` message from the given peer.
89          */
90         void handle_update_fee(byte[] their_node_id, UpdateFee msg);
91         /**Handle an incoming `announcement_signatures` message from the given peer.
92          */
93         void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
94         /**Indicates a connection to the peer failed/an existing connection was lost.
95          */
96         void peer_disconnected(byte[] their_node_id);
97         /**Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
98          * 
99          * May return an `Err(())` if the features the peer supports are not sufficient to communicate
100          * with us. Implementors should be somewhat conservative about doing so, however, as other
101          * message handlers may still wish to communicate with this peer.
102          */
103         Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, bool inbound);
104         /**Handle an incoming `channel_reestablish` message from the given peer.
105          */
106         void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
107         /**Handle an incoming `channel_update` message from the given peer.
108          */
109         void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
110         /**Handle an incoming `error` message from the given peer.
111          */
112         void handle_error(byte[] their_node_id, ErrorMessage msg);
113         /**Gets the node feature flags which this handler itself supports. All available handlers are
114          * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
115          * which are broadcasted in our [`NodeAnnouncement`] message.
116          */
117         NodeFeatures provided_node_features();
118         /**Gets the init feature flags which should be sent to the given peer. All available handlers
119          * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
120          * which are sent in our [`Init`] message.
121          * 
122          * Note that this method is called before [`Self::peer_connected`].
123          */
124         InitFeatures provided_init_features(byte[] their_node_id);
125         /**Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
126          * 
127          * If it's `None`, then no particular network chain hash compatibility will be enforced when
128          * connecting to peers.
129          */
130         Option_CVec_ThirtyTwoBytesZZ get_chain_hashes();
131 }
132
133 /**
134  * A trait to describe an object which can receive channel messages.
135  * 
136  * Messages MAY be called in parallel when they originate from different `their_node_ids`, however
137  * they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
138  */
139 public class ChannelMessageHandler : CommonBase {
140         internal bindings.LDKChannelMessageHandler bindings_instance;
141         internal long instance_idx;
142
143         internal ChannelMessageHandler(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
144         ~ChannelMessageHandler() {
145                 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); }
146         }
147
148         private class LDKChannelMessageHandlerHolder { internal ChannelMessageHandler held; }
149         private class LDKChannelMessageHandlerImpl : bindings.LDKChannelMessageHandler {
150                 internal LDKChannelMessageHandlerImpl(ChannelMessageHandlerInterface arg, LDKChannelMessageHandlerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
151                 private ChannelMessageHandlerInterface arg;
152                 private LDKChannelMessageHandlerHolder impl_holder;
153                 public void handle_open_channel(long _their_node_id, long _msg) {
154                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
155                         org.ldk.structs.OpenChannel _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.OpenChannel(null, _msg); }
156                         arg.handle_open_channel(_their_node_id_conv, _msg_hu_conv);
157                                 GC.KeepAlive(arg);
158                 }
159                 public void handle_open_channel_v2(long _their_node_id, long _msg) {
160                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
161                         org.ldk.structs.OpenChannelV2 _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.OpenChannelV2(null, _msg); }
162                         arg.handle_open_channel_v2(_their_node_id_conv, _msg_hu_conv);
163                                 GC.KeepAlive(arg);
164                 }
165                 public void handle_accept_channel(long _their_node_id, long _msg) {
166                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
167                         org.ldk.structs.AcceptChannel _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AcceptChannel(null, _msg); }
168                         arg.handle_accept_channel(_their_node_id_conv, _msg_hu_conv);
169                                 GC.KeepAlive(arg);
170                 }
171                 public void handle_accept_channel_v2(long _their_node_id, long _msg) {
172                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
173                         org.ldk.structs.AcceptChannelV2 _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AcceptChannelV2(null, _msg); }
174                         arg.handle_accept_channel_v2(_their_node_id_conv, _msg_hu_conv);
175                                 GC.KeepAlive(arg);
176                 }
177                 public void handle_funding_created(long _their_node_id, long _msg) {
178                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
179                         org.ldk.structs.FundingCreated _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.FundingCreated(null, _msg); }
180                         arg.handle_funding_created(_their_node_id_conv, _msg_hu_conv);
181                                 GC.KeepAlive(arg);
182                 }
183                 public void handle_funding_signed(long _their_node_id, long _msg) {
184                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
185                         org.ldk.structs.FundingSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.FundingSigned(null, _msg); }
186                         arg.handle_funding_signed(_their_node_id_conv, _msg_hu_conv);
187                                 GC.KeepAlive(arg);
188                 }
189                 public void handle_channel_ready(long _their_node_id, long _msg) {
190                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
191                         org.ldk.structs.ChannelReady _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelReady(null, _msg); }
192                         arg.handle_channel_ready(_their_node_id_conv, _msg_hu_conv);
193                                 GC.KeepAlive(arg);
194                 }
195                 public void handle_shutdown(long _their_node_id, long _msg) {
196                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
197                         org.ldk.structs.Shutdown _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Shutdown(null, _msg); }
198                         arg.handle_shutdown(_their_node_id_conv, _msg_hu_conv);
199                                 GC.KeepAlive(arg);
200                 }
201                 public void handle_closing_signed(long _their_node_id, long _msg) {
202                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
203                         org.ldk.structs.ClosingSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ClosingSigned(null, _msg); }
204                         arg.handle_closing_signed(_their_node_id_conv, _msg_hu_conv);
205                                 GC.KeepAlive(arg);
206                 }
207                 public void handle_stfu(long _their_node_id, long _msg) {
208                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
209                         org.ldk.structs.Stfu _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Stfu(null, _msg); }
210                         arg.handle_stfu(_their_node_id_conv, _msg_hu_conv);
211                                 GC.KeepAlive(arg);
212                 }
213                 public void handle_tx_add_input(long _their_node_id, long _msg) {
214                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
215                         org.ldk.structs.TxAddInput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAddInput(null, _msg); }
216                         arg.handle_tx_add_input(_their_node_id_conv, _msg_hu_conv);
217                                 GC.KeepAlive(arg);
218                 }
219                 public void handle_tx_add_output(long _their_node_id, long _msg) {
220                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
221                         org.ldk.structs.TxAddOutput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAddOutput(null, _msg); }
222                         arg.handle_tx_add_output(_their_node_id_conv, _msg_hu_conv);
223                                 GC.KeepAlive(arg);
224                 }
225                 public void handle_tx_remove_input(long _their_node_id, long _msg) {
226                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
227                         org.ldk.structs.TxRemoveInput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxRemoveInput(null, _msg); }
228                         arg.handle_tx_remove_input(_their_node_id_conv, _msg_hu_conv);
229                                 GC.KeepAlive(arg);
230                 }
231                 public void handle_tx_remove_output(long _their_node_id, long _msg) {
232                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
233                         org.ldk.structs.TxRemoveOutput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxRemoveOutput(null, _msg); }
234                         arg.handle_tx_remove_output(_their_node_id_conv, _msg_hu_conv);
235                                 GC.KeepAlive(arg);
236                 }
237                 public void handle_tx_complete(long _their_node_id, long _msg) {
238                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
239                         org.ldk.structs.TxComplete _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxComplete(null, _msg); }
240                         arg.handle_tx_complete(_their_node_id_conv, _msg_hu_conv);
241                                 GC.KeepAlive(arg);
242                 }
243                 public void handle_tx_signatures(long _their_node_id, long _msg) {
244                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
245                         org.ldk.structs.TxSignatures _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxSignatures(null, _msg); }
246                         arg.handle_tx_signatures(_their_node_id_conv, _msg_hu_conv);
247                                 GC.KeepAlive(arg);
248                 }
249                 public void handle_tx_init_rbf(long _their_node_id, long _msg) {
250                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
251                         org.ldk.structs.TxInitRbf _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxInitRbf(null, _msg); }
252                         arg.handle_tx_init_rbf(_their_node_id_conv, _msg_hu_conv);
253                                 GC.KeepAlive(arg);
254                 }
255                 public void handle_tx_ack_rbf(long _their_node_id, long _msg) {
256                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
257                         org.ldk.structs.TxAckRbf _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAckRbf(null, _msg); }
258                         arg.handle_tx_ack_rbf(_their_node_id_conv, _msg_hu_conv);
259                                 GC.KeepAlive(arg);
260                 }
261                 public void handle_tx_abort(long _their_node_id, long _msg) {
262                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
263                         org.ldk.structs.TxAbort _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAbort(null, _msg); }
264                         arg.handle_tx_abort(_their_node_id_conv, _msg_hu_conv);
265                                 GC.KeepAlive(arg);
266                 }
267                 public void handle_update_add_htlc(long _their_node_id, long _msg) {
268                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
269                         org.ldk.structs.UpdateAddHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, _msg); }
270                         arg.handle_update_add_htlc(_their_node_id_conv, _msg_hu_conv);
271                                 GC.KeepAlive(arg);
272                 }
273                 public void handle_update_fulfill_htlc(long _their_node_id, long _msg) {
274                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
275                         org.ldk.structs.UpdateFulfillHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, _msg); }
276                         arg.handle_update_fulfill_htlc(_their_node_id_conv, _msg_hu_conv);
277                                 GC.KeepAlive(arg);
278                 }
279                 public void handle_update_fail_htlc(long _their_node_id, long _msg) {
280                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
281                         org.ldk.structs.UpdateFailHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, _msg); }
282                         arg.handle_update_fail_htlc(_their_node_id_conv, _msg_hu_conv);
283                                 GC.KeepAlive(arg);
284                 }
285                 public void handle_update_fail_malformed_htlc(long _their_node_id, long _msg) {
286                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
287                         org.ldk.structs.UpdateFailMalformedHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, _msg); }
288                         arg.handle_update_fail_malformed_htlc(_their_node_id_conv, _msg_hu_conv);
289                                 GC.KeepAlive(arg);
290                 }
291                 public void handle_commitment_signed(long _their_node_id, long _msg) {
292                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
293                         org.ldk.structs.CommitmentSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, _msg); }
294                         arg.handle_commitment_signed(_their_node_id_conv, _msg_hu_conv);
295                                 GC.KeepAlive(arg);
296                 }
297                 public void handle_revoke_and_ack(long _their_node_id, long _msg) {
298                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
299                         org.ldk.structs.RevokeAndACK _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, _msg); }
300                         arg.handle_revoke_and_ack(_their_node_id_conv, _msg_hu_conv);
301                                 GC.KeepAlive(arg);
302                 }
303                 public void handle_update_fee(long _their_node_id, long _msg) {
304                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
305                         org.ldk.structs.UpdateFee _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFee(null, _msg); }
306                         arg.handle_update_fee(_their_node_id_conv, _msg_hu_conv);
307                                 GC.KeepAlive(arg);
308                 }
309                 public void handle_announcement_signatures(long _their_node_id, long _msg) {
310                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
311                         org.ldk.structs.AnnouncementSignatures _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, _msg); }
312                         arg.handle_announcement_signatures(_their_node_id_conv, _msg_hu_conv);
313                                 GC.KeepAlive(arg);
314                 }
315                 public void peer_disconnected(long _their_node_id) {
316                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
317                         arg.peer_disconnected(_their_node_id_conv);
318                                 GC.KeepAlive(arg);
319                 }
320                 public long peer_connected(long _their_node_id, long _msg, bool _inbound) {
321                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
322                         org.ldk.structs.Init _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Init(null, _msg); }
323                         Result_NoneNoneZ ret = arg.peer_connected(_their_node_id_conv, _msg_hu_conv, _inbound);
324                                 GC.KeepAlive(arg);
325                         long result = ret.clone_ptr();
326                         return result;
327                 }
328                 public void handle_channel_reestablish(long _their_node_id, long _msg) {
329                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
330                         org.ldk.structs.ChannelReestablish _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, _msg); }
331                         arg.handle_channel_reestablish(_their_node_id_conv, _msg_hu_conv);
332                                 GC.KeepAlive(arg);
333                 }
334                 public void handle_channel_update(long _their_node_id, long _msg) {
335                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
336                         org.ldk.structs.ChannelUpdate _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, _msg); }
337                         arg.handle_channel_update(_their_node_id_conv, _msg_hu_conv);
338                                 GC.KeepAlive(arg);
339                 }
340                 public void handle_error(long _their_node_id, long _msg) {
341                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
342                         org.ldk.structs.ErrorMessage _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ErrorMessage(null, _msg); }
343                         arg.handle_error(_their_node_id_conv, _msg_hu_conv);
344                                 GC.KeepAlive(arg);
345                 }
346                 public long provided_node_features() {
347                         NodeFeatures ret = arg.provided_node_features();
348                                 GC.KeepAlive(arg);
349                         long result = ret.clone_ptr();
350                         return result;
351                 }
352                 public long provided_init_features(long _their_node_id) {
353                         byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
354                         InitFeatures ret = arg.provided_init_features(_their_node_id_conv);
355                                 GC.KeepAlive(arg);
356                         long result = ret.clone_ptr();
357                         return result;
358                 }
359                 public long get_chain_hashes() {
360                         Option_CVec_ThirtyTwoBytesZZ ret = arg.get_chain_hashes();
361                                 GC.KeepAlive(arg);
362                         long result = ret.clone_ptr();
363                         if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
364                         return result;
365                 }
366         }
367
368         /** Creates a new instance of ChannelMessageHandler from a given implementation */
369         public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProviderInterface messageSendEventsProvider_impl) {
370                 LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
371                 LDKChannelMessageHandlerImpl impl = new LDKChannelMessageHandlerImpl(arg, impl_holder);
372                 MessageSendEventsProvider messageSendEventsProvider = MessageSendEventsProvider.new_impl(messageSendEventsProvider_impl);
373                 long[] ptr_idx = bindings.LDKChannelMessageHandler_new(impl, messageSendEventsProvider.instance_idx);
374
375                 impl_holder.held = new ChannelMessageHandler(null, ptr_idx[0]);
376                 impl_holder.held.instance_idx = ptr_idx[1];
377                 impl_holder.held.bindings_instance = impl;
378                 impl_holder.held.ptrs_to.AddLast(messageSendEventsProvider);
379                 return impl_holder.held;
380         }
381
382         /**
383          * Handle an incoming `open_channel` message from the given peer.
384          */
385         public void handle_open_channel(byte[] their_node_id, org.ldk.structs.OpenChannel msg) {
386                 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
387                 GC.KeepAlive(this);
388                 GC.KeepAlive(their_node_id);
389                 GC.KeepAlive(msg);
390                 if (this != null) { this.ptrs_to.AddLast(msg); };
391         }
392
393         /**
394          * Handle an incoming `open_channel2` message from the given peer.
395          */
396         public void handle_open_channel_v2(byte[] their_node_id, org.ldk.structs.OpenChannelV2 msg) {
397                 bindings.ChannelMessageHandler_handle_open_channel_v2(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
398                 GC.KeepAlive(this);
399                 GC.KeepAlive(their_node_id);
400                 GC.KeepAlive(msg);
401                 if (this != null) { this.ptrs_to.AddLast(msg); };
402         }
403
404         /**
405          * Handle an incoming `accept_channel` message from the given peer.
406          */
407         public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.AcceptChannel msg) {
408                 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
409                 GC.KeepAlive(this);
410                 GC.KeepAlive(their_node_id);
411                 GC.KeepAlive(msg);
412                 if (this != null) { this.ptrs_to.AddLast(msg); };
413         }
414
415         /**
416          * Handle an incoming `accept_channel2` message from the given peer.
417          */
418         public void handle_accept_channel_v2(byte[] their_node_id, org.ldk.structs.AcceptChannelV2 msg) {
419                 bindings.ChannelMessageHandler_handle_accept_channel_v2(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
420                 GC.KeepAlive(this);
421                 GC.KeepAlive(their_node_id);
422                 GC.KeepAlive(msg);
423                 if (this != null) { this.ptrs_to.AddLast(msg); };
424         }
425
426         /**
427          * Handle an incoming `funding_created` message from the given peer.
428          */
429         public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
430                 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
431                 GC.KeepAlive(this);
432                 GC.KeepAlive(their_node_id);
433                 GC.KeepAlive(msg);
434                 if (this != null) { this.ptrs_to.AddLast(msg); };
435         }
436
437         /**
438          * Handle an incoming `funding_signed` message from the given peer.
439          */
440         public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
441                 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
442                 GC.KeepAlive(this);
443                 GC.KeepAlive(their_node_id);
444                 GC.KeepAlive(msg);
445                 if (this != null) { this.ptrs_to.AddLast(msg); };
446         }
447
448         /**
449          * Handle an incoming `channel_ready` message from the given peer.
450          */
451         public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
452                 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
453                 GC.KeepAlive(this);
454                 GC.KeepAlive(their_node_id);
455                 GC.KeepAlive(msg);
456                 if (this != null) { this.ptrs_to.AddLast(msg); };
457         }
458
459         /**
460          * Handle an incoming `shutdown` message from the given peer.
461          */
462         public void handle_shutdown(byte[] their_node_id, org.ldk.structs.Shutdown msg) {
463                 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
464                 GC.KeepAlive(this);
465                 GC.KeepAlive(their_node_id);
466                 GC.KeepAlive(msg);
467                 if (this != null) { this.ptrs_to.AddLast(msg); };
468         }
469
470         /**
471          * Handle an incoming `closing_signed` message from the given peer.
472          */
473         public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
474                 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
475                 GC.KeepAlive(this);
476                 GC.KeepAlive(their_node_id);
477                 GC.KeepAlive(msg);
478                 if (this != null) { this.ptrs_to.AddLast(msg); };
479         }
480
481         /**
482          * Handle an incoming `stfu` message from the given peer.
483          */
484         public void handle_stfu(byte[] their_node_id, org.ldk.structs.Stfu msg) {
485                 bindings.ChannelMessageHandler_handle_stfu(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
486                 GC.KeepAlive(this);
487                 GC.KeepAlive(their_node_id);
488                 GC.KeepAlive(msg);
489                 if (this != null) { this.ptrs_to.AddLast(msg); };
490         }
491
492         /**
493          * Handle an incoming `tx_add_input message` from the given peer.
494          */
495         public void handle_tx_add_input(byte[] their_node_id, org.ldk.structs.TxAddInput msg) {
496                 bindings.ChannelMessageHandler_handle_tx_add_input(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
497                 GC.KeepAlive(this);
498                 GC.KeepAlive(their_node_id);
499                 GC.KeepAlive(msg);
500                 if (this != null) { this.ptrs_to.AddLast(msg); };
501         }
502
503         /**
504          * Handle an incoming `tx_add_output` message from the given peer.
505          */
506         public void handle_tx_add_output(byte[] their_node_id, org.ldk.structs.TxAddOutput msg) {
507                 bindings.ChannelMessageHandler_handle_tx_add_output(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
508                 GC.KeepAlive(this);
509                 GC.KeepAlive(their_node_id);
510                 GC.KeepAlive(msg);
511                 if (this != null) { this.ptrs_to.AddLast(msg); };
512         }
513
514         /**
515          * Handle an incoming `tx_remove_input` message from the given peer.
516          */
517         public void handle_tx_remove_input(byte[] their_node_id, org.ldk.structs.TxRemoveInput msg) {
518                 bindings.ChannelMessageHandler_handle_tx_remove_input(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
519                 GC.KeepAlive(this);
520                 GC.KeepAlive(their_node_id);
521                 GC.KeepAlive(msg);
522                 if (this != null) { this.ptrs_to.AddLast(msg); };
523         }
524
525         /**
526          * Handle an incoming `tx_remove_output` message from the given peer.
527          */
528         public void handle_tx_remove_output(byte[] their_node_id, org.ldk.structs.TxRemoveOutput msg) {
529                 bindings.ChannelMessageHandler_handle_tx_remove_output(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
530                 GC.KeepAlive(this);
531                 GC.KeepAlive(their_node_id);
532                 GC.KeepAlive(msg);
533                 if (this != null) { this.ptrs_to.AddLast(msg); };
534         }
535
536         /**
537          * Handle an incoming `tx_complete message` from the given peer.
538          */
539         public void handle_tx_complete(byte[] their_node_id, org.ldk.structs.TxComplete msg) {
540                 bindings.ChannelMessageHandler_handle_tx_complete(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
541                 GC.KeepAlive(this);
542                 GC.KeepAlive(their_node_id);
543                 GC.KeepAlive(msg);
544                 if (this != null) { this.ptrs_to.AddLast(msg); };
545         }
546
547         /**
548          * Handle an incoming `tx_signatures` message from the given peer.
549          */
550         public void handle_tx_signatures(byte[] their_node_id, org.ldk.structs.TxSignatures msg) {
551                 bindings.ChannelMessageHandler_handle_tx_signatures(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
552                 GC.KeepAlive(this);
553                 GC.KeepAlive(their_node_id);
554                 GC.KeepAlive(msg);
555                 if (this != null) { this.ptrs_to.AddLast(msg); };
556         }
557
558         /**
559          * Handle an incoming `tx_init_rbf` message from the given peer.
560          */
561         public void handle_tx_init_rbf(byte[] their_node_id, org.ldk.structs.TxInitRbf msg) {
562                 bindings.ChannelMessageHandler_handle_tx_init_rbf(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
563                 GC.KeepAlive(this);
564                 GC.KeepAlive(their_node_id);
565                 GC.KeepAlive(msg);
566                 if (this != null) { this.ptrs_to.AddLast(msg); };
567         }
568
569         /**
570          * Handle an incoming `tx_ack_rbf` message from the given peer.
571          */
572         public void handle_tx_ack_rbf(byte[] their_node_id, org.ldk.structs.TxAckRbf msg) {
573                 bindings.ChannelMessageHandler_handle_tx_ack_rbf(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
574                 GC.KeepAlive(this);
575                 GC.KeepAlive(their_node_id);
576                 GC.KeepAlive(msg);
577                 if (this != null) { this.ptrs_to.AddLast(msg); };
578         }
579
580         /**
581          * Handle an incoming `tx_abort message` from the given peer.
582          */
583         public void handle_tx_abort(byte[] their_node_id, org.ldk.structs.TxAbort msg) {
584                 bindings.ChannelMessageHandler_handle_tx_abort(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
585                 GC.KeepAlive(this);
586                 GC.KeepAlive(their_node_id);
587                 GC.KeepAlive(msg);
588                 if (this != null) { this.ptrs_to.AddLast(msg); };
589         }
590
591         /**
592          * Handle an incoming `update_add_htlc` message from the given peer.
593          */
594         public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
595                 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
596                 GC.KeepAlive(this);
597                 GC.KeepAlive(their_node_id);
598                 GC.KeepAlive(msg);
599                 if (this != null) { this.ptrs_to.AddLast(msg); };
600         }
601
602         /**
603          * Handle an incoming `update_fulfill_htlc` message from the given peer.
604          */
605         public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
606                 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
607                 GC.KeepAlive(this);
608                 GC.KeepAlive(their_node_id);
609                 GC.KeepAlive(msg);
610                 if (this != null) { this.ptrs_to.AddLast(msg); };
611         }
612
613         /**
614          * Handle an incoming `update_fail_htlc` message from the given peer.
615          */
616         public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
617                 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
618                 GC.KeepAlive(this);
619                 GC.KeepAlive(their_node_id);
620                 GC.KeepAlive(msg);
621                 if (this != null) { this.ptrs_to.AddLast(msg); };
622         }
623
624         /**
625          * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
626          */
627         public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
628                 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
629                 GC.KeepAlive(this);
630                 GC.KeepAlive(their_node_id);
631                 GC.KeepAlive(msg);
632                 if (this != null) { this.ptrs_to.AddLast(msg); };
633         }
634
635         /**
636          * Handle an incoming `commitment_signed` message from the given peer.
637          */
638         public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
639                 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
640                 GC.KeepAlive(this);
641                 GC.KeepAlive(their_node_id);
642                 GC.KeepAlive(msg);
643                 if (this != null) { this.ptrs_to.AddLast(msg); };
644         }
645
646         /**
647          * Handle an incoming `revoke_and_ack` message from the given peer.
648          */
649         public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
650                 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
651                 GC.KeepAlive(this);
652                 GC.KeepAlive(their_node_id);
653                 GC.KeepAlive(msg);
654                 if (this != null) { this.ptrs_to.AddLast(msg); };
655         }
656
657         /**
658          * Handle an incoming `update_fee` message from the given peer.
659          */
660         public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
661                 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
662                 GC.KeepAlive(this);
663                 GC.KeepAlive(their_node_id);
664                 GC.KeepAlive(msg);
665                 if (this != null) { this.ptrs_to.AddLast(msg); };
666         }
667
668         /**
669          * Handle an incoming `announcement_signatures` message from the given peer.
670          */
671         public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
672                 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
673                 GC.KeepAlive(this);
674                 GC.KeepAlive(their_node_id);
675                 GC.KeepAlive(msg);
676                 if (this != null) { this.ptrs_to.AddLast(msg); };
677         }
678
679         /**
680          * Indicates a connection to the peer failed/an existing connection was lost.
681          */
682         public void peer_disconnected(byte[] their_node_id) {
683                 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
684                 GC.KeepAlive(this);
685                 GC.KeepAlive(their_node_id);
686         }
687
688         /**
689          * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
690          * 
691          * May return an `Err(())` if the features the peer supports are not sufficient to communicate
692          * with us. Implementors should be somewhat conservative about doing so, however, as other
693          * message handlers may still wish to communicate with this peer.
694          */
695         public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg, bool inbound) {
696                 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr, inbound);
697                 GC.KeepAlive(this);
698                 GC.KeepAlive(their_node_id);
699                 GC.KeepAlive(msg);
700                 GC.KeepAlive(inbound);
701                 if (ret >= 0 && ret <= 4096) { return null; }
702                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
703                 if (this != null) { this.ptrs_to.AddLast(msg); };
704                 return ret_hu_conv;
705         }
706
707         /**
708          * Handle an incoming `channel_reestablish` message from the given peer.
709          */
710         public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
711                 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
712                 GC.KeepAlive(this);
713                 GC.KeepAlive(their_node_id);
714                 GC.KeepAlive(msg);
715                 if (this != null) { this.ptrs_to.AddLast(msg); };
716         }
717
718         /**
719          * Handle an incoming `channel_update` message from the given peer.
720          */
721         public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
722                 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
723                 GC.KeepAlive(this);
724                 GC.KeepAlive(their_node_id);
725                 GC.KeepAlive(msg);
726                 if (this != null) { this.ptrs_to.AddLast(msg); };
727         }
728
729         /**
730          * Handle an incoming `error` message from the given peer.
731          */
732         public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
733                 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
734                 GC.KeepAlive(this);
735                 GC.KeepAlive(their_node_id);
736                 GC.KeepAlive(msg);
737                 if (this != null) { this.ptrs_to.AddLast(msg); };
738         }
739
740         /**
741          * Gets the node feature flags which this handler itself supports. All available handlers are
742          * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
743          * which are broadcasted in our [`NodeAnnouncement`] message.
744          */
745         public NodeFeatures provided_node_features() {
746                 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
747                 GC.KeepAlive(this);
748                 if (ret >= 0 && ret <= 4096) { return null; }
749                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
750                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
751                 return ret_hu_conv;
752         }
753
754         /**
755          * Gets the init feature flags which should be sent to the given peer. All available handlers
756          * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
757          * which are sent in our [`Init`] message.
758          * 
759          * Note that this method is called before [`Self::peer_connected`].
760          */
761         public InitFeatures provided_init_features(byte[] their_node_id) {
762                 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
763                 GC.KeepAlive(this);
764                 GC.KeepAlive(their_node_id);
765                 if (ret >= 0 && ret <= 4096) { return null; }
766                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
767                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
768                 return ret_hu_conv;
769         }
770
771         /**
772          * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
773          * 
774          * If it's `None`, then no particular network chain hash compatibility will be enforced when
775          * connecting to peers.
776          */
777         public Option_CVec_ThirtyTwoBytesZZ get_chain_hashes() {
778                 long ret = bindings.ChannelMessageHandler_get_chain_hashes(this.ptr);
779                 GC.KeepAlive(this);
780                 if (ret >= 0 && ret <= 4096) { return null; }
781                 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
782                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
783                 return ret_hu_conv;
784         }
785
786 }
787 } } }