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