[Java] Update auto-generated Java files
[ldk-java] / src / main / java / org / ldk / structs / ChannelMessageHandler.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * A trait to describe an object which can receive channel messages.
12  * 
13  * Messages MAY be called in parallel when they originate from different their_node_ids, however
14  * they MUST NOT be called in parallel when the two calls have the same their_node_id.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelMessageHandler extends CommonBase {
18         final bindings.LDKChannelMessageHandler bindings_instance;
19         ChannelMessageHandler(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
20         private ChannelMessageHandler(bindings.LDKChannelMessageHandler arg, bindings.LDKMessageSendEventsProvider MessageSendEventsProvider) {
21                 super(bindings.LDKChannelMessageHandler_new(arg, MessageSendEventsProvider));
22                 this.ptrs_to.add(arg);
23                 this.ptrs_to.add(MessageSendEventsProvider);
24                 this.bindings_instance = arg;
25         }
26         @Override @SuppressWarnings("deprecation")
27         protected void finalize() throws Throwable {
28                 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); } super.finalize();
29         }
30
31         public static interface ChannelMessageHandlerInterface {
32                 /**
33                  * Handle an incoming open_channel message from the given peer.
34                  */
35                 void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg);
36                 /**
37                  * Handle an incoming accept_channel message from the given peer.
38                  */
39                 void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg);
40                 /**
41                  * Handle an incoming funding_created message from the given peer.
42                  */
43                 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
44                 /**
45                  * Handle an incoming funding_signed message from the given peer.
46                  */
47                 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
48                 /**
49                  * Handle an incoming channel_ready message from the given peer.
50                  */
51                 void handle_channel_ready(byte[] their_node_id, ChannelReady msg);
52                 /**
53                  * Handle an incoming shutdown message from the given peer.
54                  */
55                 void handle_shutdown(byte[] their_node_id, InitFeatures their_features, Shutdown msg);
56                 /**
57                  * Handle an incoming closing_signed message from the given peer.
58                  */
59                 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
60                 /**
61                  * Handle an incoming update_add_htlc message from the given peer.
62                  */
63                 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
64                 /**
65                  * Handle an incoming update_fulfill_htlc message from the given peer.
66                  */
67                 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
68                 /**
69                  * Handle an incoming update_fail_htlc message from the given peer.
70                  */
71                 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
72                 /**
73                  * Handle an incoming update_fail_malformed_htlc message from the given peer.
74                  */
75                 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
76                 /**
77                  * Handle an incoming commitment_signed message from the given peer.
78                  */
79                 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
80                 /**
81                  * Handle an incoming revoke_and_ack message from the given peer.
82                  */
83                 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
84                 /**
85                  * Handle an incoming update_fee message from the given peer.
86                  */
87                 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
88                 /**
89                  * Handle an incoming announcement_signatures message from the given peer.
90                  */
91                 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
92                 /**
93                  * Indicates a connection to the peer failed/an existing connection was lost. If no connection
94                  * is believed to be possible in the future (eg they're sending us messages we don't
95                  * understand or indicate they require unknown feature bits), no_connection_possible is set
96                  * and any outstanding channels should be failed.
97                  */
98                 void peer_disconnected(byte[] their_node_id, boolean no_connection_possible);
99                 /**
100                  * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
101                  */
102                 void peer_connected(byte[] their_node_id, Init msg);
103                 /**
104                  * Handle an incoming channel_reestablish message from the given peer.
105                  */
106                 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
107                 /**
108                  * Handle an incoming channel update from the given peer.
109                  */
110                 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
111                 /**
112                  * Handle an incoming error message from the given peer.
113                  */
114                 void handle_error(byte[] their_node_id, ErrorMessage msg);
115                 /**
116                  * Gets the node feature flags which this handler itself supports. All available handlers are
117                  * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
118                  * which are broadcasted in our [`NodeAnnouncement`] message.
119                  */
120                 NodeFeatures provided_node_features();
121                 /**
122                  * Gets the init feature flags which should be sent to the given peer. All available handlers
123                  * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
124                  * which are sent in our [`Init`] message.
125                  * 
126                  * Note that this method is called before [`Self::peer_connected`].
127                  */
128                 InitFeatures provided_init_features(byte[] their_node_id);
129         }
130         private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
131         public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
132                 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
133                 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
134                         @Override public void handle_open_channel(byte[] their_node_id, long their_features, long msg) {
135                                 org.ldk.structs.InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new org.ldk.structs.InitFeatures(null, their_features); }
136                                 if (their_features_hu_conv != null) { their_features_hu_conv.ptrs_to.add(this); };
137                                 org.ldk.structs.OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannel(null, msg); }
138                                 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
139                                 Reference.reachabilityFence(arg);
140                         }
141                         @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
142                                 org.ldk.structs.InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new org.ldk.structs.InitFeatures(null, their_features); }
143                                 if (their_features_hu_conv != null) { their_features_hu_conv.ptrs_to.add(this); };
144                                 org.ldk.structs.AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannel(null, msg); }
145                                 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
146                                 Reference.reachabilityFence(arg);
147                         }
148                         @Override public void handle_funding_created(byte[] their_node_id, long msg) {
149                                 org.ldk.structs.FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingCreated(null, msg); }
150                                 arg.handle_funding_created(their_node_id, msg_hu_conv);
151                                 Reference.reachabilityFence(arg);
152                         }
153                         @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
154                                 org.ldk.structs.FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingSigned(null, msg); }
155                                 arg.handle_funding_signed(their_node_id, msg_hu_conv);
156                                 Reference.reachabilityFence(arg);
157                         }
158                         @Override public void handle_channel_ready(byte[] their_node_id, long msg) {
159                                 org.ldk.structs.ChannelReady msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReady(null, msg); }
160                                 arg.handle_channel_ready(their_node_id, msg_hu_conv);
161                                 Reference.reachabilityFence(arg);
162                         }
163                         @Override public void handle_shutdown(byte[] their_node_id, long their_features, long msg) {
164                                 org.ldk.structs.InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new org.ldk.structs.InitFeatures(null, their_features); }
165                                 org.ldk.structs.Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Shutdown(null, msg); }
166                                 arg.handle_shutdown(their_node_id, their_features_hu_conv, msg_hu_conv);
167                                 Reference.reachabilityFence(arg);
168                         }
169                         @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
170                                 org.ldk.structs.ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ClosingSigned(null, msg); }
171                                 arg.handle_closing_signed(their_node_id, msg_hu_conv);
172                                 Reference.reachabilityFence(arg);
173                         }
174                         @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
175                                 org.ldk.structs.UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, msg); }
176                                 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
177                                 Reference.reachabilityFence(arg);
178                         }
179                         @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
180                                 org.ldk.structs.UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, msg); }
181                                 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
182                                 Reference.reachabilityFence(arg);
183                         }
184                         @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
185                                 org.ldk.structs.UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, msg); }
186                                 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
187                                 Reference.reachabilityFence(arg);
188                         }
189                         @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
190                                 org.ldk.structs.UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, msg); }
191                                 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
192                                 Reference.reachabilityFence(arg);
193                         }
194                         @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
195                                 org.ldk.structs.CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, msg); }
196                                 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
197                                 Reference.reachabilityFence(arg);
198                         }
199                         @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
200                                 org.ldk.structs.RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, msg); }
201                                 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
202                                 Reference.reachabilityFence(arg);
203                         }
204                         @Override public void handle_update_fee(byte[] their_node_id, long msg) {
205                                 org.ldk.structs.UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFee(null, msg); }
206                                 arg.handle_update_fee(their_node_id, msg_hu_conv);
207                                 Reference.reachabilityFence(arg);
208                         }
209                         @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
210                                 org.ldk.structs.AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, msg); }
211                                 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
212                                 Reference.reachabilityFence(arg);
213                         }
214                         @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
215                                 arg.peer_disconnected(their_node_id, no_connection_possible);
216                                 Reference.reachabilityFence(arg);
217                         }
218                         @Override public void peer_connected(byte[] their_node_id, long msg) {
219                                 org.ldk.structs.Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Init(null, msg); }
220                                 arg.peer_connected(their_node_id, msg_hu_conv);
221                                 Reference.reachabilityFence(arg);
222                         }
223                         @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
224                                 org.ldk.structs.ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, msg); }
225                                 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
226                                 Reference.reachabilityFence(arg);
227                         }
228                         @Override public void handle_channel_update(byte[] their_node_id, long msg) {
229                                 org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); }
230                                 arg.handle_channel_update(their_node_id, msg_hu_conv);
231                                 Reference.reachabilityFence(arg);
232                         }
233                         @Override public void handle_error(byte[] their_node_id, long msg) {
234                                 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
235                                 arg.handle_error(their_node_id, msg_hu_conv);
236                                 Reference.reachabilityFence(arg);
237                         }
238                         @Override public long provided_node_features() {
239                                 NodeFeatures ret = arg.provided_node_features();
240                                 Reference.reachabilityFence(arg);
241                                 long result = ret == null ? 0 : ret.clone_ptr();
242                                 return result;
243                         }
244                         @Override public long provided_init_features(byte[] their_node_id) {
245                                 InitFeatures ret = arg.provided_init_features(their_node_id);
246                                 Reference.reachabilityFence(arg);
247                                 long result = ret == null ? 0 : ret.clone_ptr();
248                                 return result;
249                         }
250                 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
251                 return impl_holder.held;
252         }
253
254         /**
255          * Gets the underlying MessageSendEventsProvider.
256          */
257         public MessageSendEventsProvider get_message_send_events_provider() {
258                 MessageSendEventsProvider res = new MessageSendEventsProvider(null, bindings.LDKChannelMessageHandler_get_MessageSendEventsProvider(this.ptr));
259                 this.ptrs_to.add(res);
260                 return res;
261         }
262
263         /**
264          * Handle an incoming open_channel message from the given peer.
265          */
266         public void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg) {
267                 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), their_features == null ? 0 : their_features.ptr, msg == null ? 0 : msg.ptr);
268                 Reference.reachabilityFence(this);
269                 Reference.reachabilityFence(their_node_id);
270                 Reference.reachabilityFence(their_features);
271                 Reference.reachabilityFence(msg);
272                 if (this != null) { this.ptrs_to.add(their_features); };
273                 if (this != null) { this.ptrs_to.add(msg); };
274         }
275
276         /**
277          * Handle an incoming accept_channel message from the given peer.
278          */
279         public void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg) {
280                 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), their_features == null ? 0 : their_features.ptr, msg == null ? 0 : msg.ptr);
281                 Reference.reachabilityFence(this);
282                 Reference.reachabilityFence(their_node_id);
283                 Reference.reachabilityFence(their_features);
284                 Reference.reachabilityFence(msg);
285                 if (this != null) { this.ptrs_to.add(their_features); };
286                 if (this != null) { this.ptrs_to.add(msg); };
287         }
288
289         /**
290          * Handle an incoming funding_created message from the given peer.
291          */
292         public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
293                 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
294                 Reference.reachabilityFence(this);
295                 Reference.reachabilityFence(their_node_id);
296                 Reference.reachabilityFence(msg);
297                 if (this != null) { this.ptrs_to.add(msg); };
298         }
299
300         /**
301          * Handle an incoming funding_signed message from the given peer.
302          */
303         public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
304                 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
305                 Reference.reachabilityFence(this);
306                 Reference.reachabilityFence(their_node_id);
307                 Reference.reachabilityFence(msg);
308                 if (this != null) { this.ptrs_to.add(msg); };
309         }
310
311         /**
312          * Handle an incoming channel_ready message from the given peer.
313          */
314         public void handle_channel_ready(byte[] their_node_id, ChannelReady msg) {
315                 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
316                 Reference.reachabilityFence(this);
317                 Reference.reachabilityFence(their_node_id);
318                 Reference.reachabilityFence(msg);
319                 if (this != null) { this.ptrs_to.add(msg); };
320         }
321
322         /**
323          * Handle an incoming shutdown message from the given peer.
324          */
325         public void handle_shutdown(byte[] their_node_id, InitFeatures their_features, Shutdown msg) {
326                 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), their_features == null ? 0 : their_features.ptr, msg == null ? 0 : msg.ptr);
327                 Reference.reachabilityFence(this);
328                 Reference.reachabilityFence(their_node_id);
329                 Reference.reachabilityFence(their_features);
330                 Reference.reachabilityFence(msg);
331                 if (this != null) { this.ptrs_to.add(their_features); };
332                 if (this != null) { this.ptrs_to.add(msg); };
333         }
334
335         /**
336          * Handle an incoming closing_signed message from the given peer.
337          */
338         public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
339                 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
340                 Reference.reachabilityFence(this);
341                 Reference.reachabilityFence(their_node_id);
342                 Reference.reachabilityFence(msg);
343                 if (this != null) { this.ptrs_to.add(msg); };
344         }
345
346         /**
347          * Handle an incoming update_add_htlc message from the given peer.
348          */
349         public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
350                 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
351                 Reference.reachabilityFence(this);
352                 Reference.reachabilityFence(their_node_id);
353                 Reference.reachabilityFence(msg);
354                 if (this != null) { this.ptrs_to.add(msg); };
355         }
356
357         /**
358          * Handle an incoming update_fulfill_htlc message from the given peer.
359          */
360         public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
361                 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
362                 Reference.reachabilityFence(this);
363                 Reference.reachabilityFence(their_node_id);
364                 Reference.reachabilityFence(msg);
365                 if (this != null) { this.ptrs_to.add(msg); };
366         }
367
368         /**
369          * Handle an incoming update_fail_htlc message from the given peer.
370          */
371         public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
372                 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
373                 Reference.reachabilityFence(this);
374                 Reference.reachabilityFence(their_node_id);
375                 Reference.reachabilityFence(msg);
376                 if (this != null) { this.ptrs_to.add(msg); };
377         }
378
379         /**
380          * Handle an incoming update_fail_malformed_htlc message from the given peer.
381          */
382         public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
383                 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
384                 Reference.reachabilityFence(this);
385                 Reference.reachabilityFence(their_node_id);
386                 Reference.reachabilityFence(msg);
387                 if (this != null) { this.ptrs_to.add(msg); };
388         }
389
390         /**
391          * Handle an incoming commitment_signed message from the given peer.
392          */
393         public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
394                 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
395                 Reference.reachabilityFence(this);
396                 Reference.reachabilityFence(their_node_id);
397                 Reference.reachabilityFence(msg);
398                 if (this != null) { this.ptrs_to.add(msg); };
399         }
400
401         /**
402          * Handle an incoming revoke_and_ack message from the given peer.
403          */
404         public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
405                 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
406                 Reference.reachabilityFence(this);
407                 Reference.reachabilityFence(their_node_id);
408                 Reference.reachabilityFence(msg);
409                 if (this != null) { this.ptrs_to.add(msg); };
410         }
411
412         /**
413          * Handle an incoming update_fee message from the given peer.
414          */
415         public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
416                 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
417                 Reference.reachabilityFence(this);
418                 Reference.reachabilityFence(their_node_id);
419                 Reference.reachabilityFence(msg);
420                 if (this != null) { this.ptrs_to.add(msg); };
421         }
422
423         /**
424          * Handle an incoming announcement_signatures message from the given peer.
425          */
426         public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
427                 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
428                 Reference.reachabilityFence(this);
429                 Reference.reachabilityFence(their_node_id);
430                 Reference.reachabilityFence(msg);
431                 if (this != null) { this.ptrs_to.add(msg); };
432         }
433
434         /**
435          * Indicates a connection to the peer failed/an existing connection was lost. If no connection
436          * is believed to be possible in the future (eg they're sending us messages we don't
437          * understand or indicate they require unknown feature bits), no_connection_possible is set
438          * and any outstanding channels should be failed.
439          */
440         public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
441                 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), no_connection_possible);
442                 Reference.reachabilityFence(this);
443                 Reference.reachabilityFence(their_node_id);
444                 Reference.reachabilityFence(no_connection_possible);
445         }
446
447         /**
448          * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
449          */
450         public void peer_connected(byte[] their_node_id, Init msg) {
451                 bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
452                 Reference.reachabilityFence(this);
453                 Reference.reachabilityFence(their_node_id);
454                 Reference.reachabilityFence(msg);
455                 if (this != null) { this.ptrs_to.add(msg); };
456         }
457
458         /**
459          * Handle an incoming channel_reestablish message from the given peer.
460          */
461         public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
462                 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
463                 Reference.reachabilityFence(this);
464                 Reference.reachabilityFence(their_node_id);
465                 Reference.reachabilityFence(msg);
466                 if (this != null) { this.ptrs_to.add(msg); };
467         }
468
469         /**
470          * Handle an incoming channel update from the given peer.
471          */
472         public void handle_channel_update(byte[] their_node_id, ChannelUpdate msg) {
473                 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
474                 Reference.reachabilityFence(this);
475                 Reference.reachabilityFence(their_node_id);
476                 Reference.reachabilityFence(msg);
477                 if (this != null) { this.ptrs_to.add(msg); };
478         }
479
480         /**
481          * Handle an incoming error message from the given peer.
482          */
483         public void handle_error(byte[] their_node_id, ErrorMessage msg) {
484                 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
485                 Reference.reachabilityFence(this);
486                 Reference.reachabilityFence(their_node_id);
487                 Reference.reachabilityFence(msg);
488                 if (this != null) { this.ptrs_to.add(msg); };
489         }
490
491         /**
492          * Gets the node feature flags which this handler itself supports. All available handlers are
493          * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
494          * which are broadcasted in our [`NodeAnnouncement`] message.
495          */
496         public NodeFeatures provided_node_features() {
497                 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
498                 Reference.reachabilityFence(this);
499                 if (ret >= 0 && ret <= 4096) { return null; }
500                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
501                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
502                 return ret_hu_conv;
503         }
504
505         /**
506          * Gets the init feature flags which should be sent to the given peer. All available handlers
507          * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
508          * which are sent in our [`Init`] message.
509          * 
510          * Note that this method is called before [`Self::peer_connected`].
511          */
512         public InitFeatures provided_init_features(byte[] their_node_id) {
513                 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
514                 Reference.reachabilityFence(this);
515                 Reference.reachabilityFence(their_node_id);
516                 if (ret >= 0 && ret <= 4096) { return null; }
517                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
518                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
519                 return ret_hu_conv;
520         }
521
522 }