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