1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
11 * A trait to describe an object which can receive channel messages.
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`.
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;
26 @Override @SuppressWarnings("deprecation")
27 protected void finalize() throws Throwable {
28 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); } super.finalize();
31 * Destroys the object, freeing associated resources. After this call, any access
32 * to this object may result in a SEGFAULT or worse.
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
39 public void destroy() {
40 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); }
43 public static interface ChannelMessageHandlerInterface {
45 * Handle an incoming `open_channel` message from the given peer.
47 void handle_open_channel(byte[] their_node_id, OpenChannel msg);
49 * Handle an incoming `open_channel2` message from the given peer.
51 void handle_open_channel_v2(byte[] their_node_id, OpenChannelV2 msg);
53 * Handle an incoming `accept_channel` message from the given peer.
55 void handle_accept_channel(byte[] their_node_id, AcceptChannel msg);
57 * Handle an incoming `accept_channel2` message from the given peer.
59 void handle_accept_channel_v2(byte[] their_node_id, AcceptChannelV2 msg);
61 * Handle an incoming `funding_created` message from the given peer.
63 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
65 * Handle an incoming `funding_signed` message from the given peer.
67 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
69 * Handle an incoming `channel_ready` message from the given peer.
71 void handle_channel_ready(byte[] their_node_id, ChannelReady msg);
73 * Handle an incoming `shutdown` message from the given peer.
75 void handle_shutdown(byte[] their_node_id, Shutdown msg);
77 * Handle an incoming `closing_signed` message from the given peer.
79 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
81 * Handle an incoming `tx_add_input message` from the given peer.
83 void handle_tx_add_input(byte[] their_node_id, TxAddInput msg);
85 * Handle an incoming `tx_add_output` message from the given peer.
87 void handle_tx_add_output(byte[] their_node_id, TxAddOutput msg);
89 * Handle an incoming `tx_remove_input` message from the given peer.
91 void handle_tx_remove_input(byte[] their_node_id, TxRemoveInput msg);
93 * Handle an incoming `tx_remove_output` message from the given peer.
95 void handle_tx_remove_output(byte[] their_node_id, TxRemoveOutput msg);
97 * Handle an incoming `tx_complete message` from the given peer.
99 void handle_tx_complete(byte[] their_node_id, TxComplete msg);
101 * Handle an incoming `tx_signatures` message from the given peer.
103 void handle_tx_signatures(byte[] their_node_id, TxSignatures msg);
105 * Handle an incoming `tx_init_rbf` message from the given peer.
107 void handle_tx_init_rbf(byte[] their_node_id, TxInitRbf msg);
109 * Handle an incoming `tx_ack_rbf` message from the given peer.
111 void handle_tx_ack_rbf(byte[] their_node_id, TxAckRbf msg);
113 * Handle an incoming `tx_abort message` from the given peer.
115 void handle_tx_abort(byte[] their_node_id, TxAbort msg);
117 * Handle an incoming `update_add_htlc` message from the given peer.
119 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
121 * Handle an incoming `update_fulfill_htlc` message from the given peer.
123 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
125 * Handle an incoming `update_fail_htlc` message from the given peer.
127 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
129 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
131 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
133 * Handle an incoming `commitment_signed` message from the given peer.
135 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
137 * Handle an incoming `revoke_and_ack` message from the given peer.
139 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
141 * Handle an incoming `update_fee` message from the given peer.
143 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
145 * Handle an incoming `announcement_signatures` message from the given peer.
147 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
149 * Indicates a connection to the peer failed/an existing connection was lost.
151 void peer_disconnected(byte[] their_node_id);
153 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
155 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
156 * with us. Implementors should be somewhat conservative about doing so, however, as other
157 * message handlers may still wish to communicate with this peer.
159 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, boolean inbound);
161 * Handle an incoming `channel_reestablish` message from the given peer.
163 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
165 * Handle an incoming `channel_update` message from the given peer.
167 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
169 * Handle an incoming `error` message from the given peer.
171 void handle_error(byte[] their_node_id, ErrorMessage msg);
173 * Gets the node feature flags which this handler itself supports. All available handlers are
174 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
175 * which are broadcasted in our [`NodeAnnouncement`] message.
177 NodeFeatures provided_node_features();
179 * Gets the init feature flags which should be sent to the given peer. All available handlers
180 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
181 * which are sent in our [`Init`] message.
183 * Note that this method is called before [`Self::peer_connected`].
185 InitFeatures provided_init_features(byte[] their_node_id);
187 * Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports.
189 * If it's `None`, then no particular network chain hash compatibility will be enforced when
190 * connecting to peers.
192 Option_CVec_ThirtyTwoBytesZZ get_genesis_hashes();
194 private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
195 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
196 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
197 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
198 @Override public void handle_open_channel(byte[] their_node_id, long msg) {
199 org.ldk.structs.OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannel(null, msg); }
200 arg.handle_open_channel(their_node_id, msg_hu_conv);
201 Reference.reachabilityFence(arg);
203 @Override public void handle_open_channel_v2(byte[] their_node_id, long msg) {
204 org.ldk.structs.OpenChannelV2 msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannelV2(null, msg); }
205 arg.handle_open_channel_v2(their_node_id, msg_hu_conv);
206 Reference.reachabilityFence(arg);
208 @Override public void handle_accept_channel(byte[] their_node_id, long msg) {
209 org.ldk.structs.AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannel(null, msg); }
210 arg.handle_accept_channel(their_node_id, msg_hu_conv);
211 Reference.reachabilityFence(arg);
213 @Override public void handle_accept_channel_v2(byte[] their_node_id, long msg) {
214 org.ldk.structs.AcceptChannelV2 msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannelV2(null, msg); }
215 arg.handle_accept_channel_v2(their_node_id, msg_hu_conv);
216 Reference.reachabilityFence(arg);
218 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
219 org.ldk.structs.FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingCreated(null, msg); }
220 arg.handle_funding_created(their_node_id, msg_hu_conv);
221 Reference.reachabilityFence(arg);
223 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
224 org.ldk.structs.FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingSigned(null, msg); }
225 arg.handle_funding_signed(their_node_id, msg_hu_conv);
226 Reference.reachabilityFence(arg);
228 @Override public void handle_channel_ready(byte[] their_node_id, long msg) {
229 org.ldk.structs.ChannelReady msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReady(null, msg); }
230 arg.handle_channel_ready(their_node_id, msg_hu_conv);
231 Reference.reachabilityFence(arg);
233 @Override public void handle_shutdown(byte[] their_node_id, long msg) {
234 org.ldk.structs.Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Shutdown(null, msg); }
235 arg.handle_shutdown(their_node_id, msg_hu_conv);
236 Reference.reachabilityFence(arg);
238 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
239 org.ldk.structs.ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ClosingSigned(null, msg); }
240 arg.handle_closing_signed(their_node_id, msg_hu_conv);
241 Reference.reachabilityFence(arg);
243 @Override public void handle_tx_add_input(byte[] their_node_id, long msg) {
244 org.ldk.structs.TxAddInput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAddInput(null, msg); }
245 arg.handle_tx_add_input(their_node_id, msg_hu_conv);
246 Reference.reachabilityFence(arg);
248 @Override public void handle_tx_add_output(byte[] their_node_id, long msg) {
249 org.ldk.structs.TxAddOutput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAddOutput(null, msg); }
250 arg.handle_tx_add_output(their_node_id, msg_hu_conv);
251 Reference.reachabilityFence(arg);
253 @Override public void handle_tx_remove_input(byte[] their_node_id, long msg) {
254 org.ldk.structs.TxRemoveInput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxRemoveInput(null, msg); }
255 arg.handle_tx_remove_input(their_node_id, msg_hu_conv);
256 Reference.reachabilityFence(arg);
258 @Override public void handle_tx_remove_output(byte[] their_node_id, long msg) {
259 org.ldk.structs.TxRemoveOutput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxRemoveOutput(null, msg); }
260 arg.handle_tx_remove_output(their_node_id, msg_hu_conv);
261 Reference.reachabilityFence(arg);
263 @Override public void handle_tx_complete(byte[] their_node_id, long msg) {
264 org.ldk.structs.TxComplete msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxComplete(null, msg); }
265 arg.handle_tx_complete(their_node_id, msg_hu_conv);
266 Reference.reachabilityFence(arg);
268 @Override public void handle_tx_signatures(byte[] their_node_id, long msg) {
269 org.ldk.structs.TxSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxSignatures(null, msg); }
270 arg.handle_tx_signatures(their_node_id, msg_hu_conv);
271 Reference.reachabilityFence(arg);
273 @Override public void handle_tx_init_rbf(byte[] their_node_id, long msg) {
274 org.ldk.structs.TxInitRbf msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxInitRbf(null, msg); }
275 arg.handle_tx_init_rbf(their_node_id, msg_hu_conv);
276 Reference.reachabilityFence(arg);
278 @Override public void handle_tx_ack_rbf(byte[] their_node_id, long msg) {
279 org.ldk.structs.TxAckRbf msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAckRbf(null, msg); }
280 arg.handle_tx_ack_rbf(their_node_id, msg_hu_conv);
281 Reference.reachabilityFence(arg);
283 @Override public void handle_tx_abort(byte[] their_node_id, long msg) {
284 org.ldk.structs.TxAbort msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAbort(null, msg); }
285 arg.handle_tx_abort(their_node_id, msg_hu_conv);
286 Reference.reachabilityFence(arg);
288 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
289 org.ldk.structs.UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, msg); }
290 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
291 Reference.reachabilityFence(arg);
293 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
294 org.ldk.structs.UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, msg); }
295 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
296 Reference.reachabilityFence(arg);
298 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
299 org.ldk.structs.UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, msg); }
300 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
301 Reference.reachabilityFence(arg);
303 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
304 org.ldk.structs.UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, msg); }
305 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
306 Reference.reachabilityFence(arg);
308 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
309 org.ldk.structs.CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, msg); }
310 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
311 Reference.reachabilityFence(arg);
313 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
314 org.ldk.structs.RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, msg); }
315 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
316 Reference.reachabilityFence(arg);
318 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
319 org.ldk.structs.UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFee(null, msg); }
320 arg.handle_update_fee(their_node_id, msg_hu_conv);
321 Reference.reachabilityFence(arg);
323 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
324 org.ldk.structs.AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, msg); }
325 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
326 Reference.reachabilityFence(arg);
328 @Override public void peer_disconnected(byte[] their_node_id) {
329 arg.peer_disconnected(their_node_id);
330 Reference.reachabilityFence(arg);
332 @Override public long peer_connected(byte[] their_node_id, long msg, boolean inbound) {
333 org.ldk.structs.Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Init(null, msg); }
334 Result_NoneNoneZ ret = arg.peer_connected(their_node_id, msg_hu_conv, inbound);
335 Reference.reachabilityFence(arg);
336 long result = ret == null ? 0 : ret.clone_ptr();
339 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
340 org.ldk.structs.ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, msg); }
341 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
342 Reference.reachabilityFence(arg);
344 @Override public void handle_channel_update(byte[] their_node_id, long msg) {
345 org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); }
346 arg.handle_channel_update(their_node_id, msg_hu_conv);
347 Reference.reachabilityFence(arg);
349 @Override public void handle_error(byte[] their_node_id, long msg) {
350 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
351 arg.handle_error(their_node_id, msg_hu_conv);
352 Reference.reachabilityFence(arg);
354 @Override public long provided_node_features() {
355 NodeFeatures ret = arg.provided_node_features();
356 Reference.reachabilityFence(arg);
357 long result = ret == null ? 0 : ret.clone_ptr();
360 @Override public long provided_init_features(byte[] their_node_id) {
361 InitFeatures ret = arg.provided_init_features(their_node_id);
362 Reference.reachabilityFence(arg);
363 long result = ret == null ? 0 : ret.clone_ptr();
366 @Override public long get_genesis_hashes() {
367 Option_CVec_ThirtyTwoBytesZZ ret = arg.get_genesis_hashes();
368 Reference.reachabilityFence(arg);
369 long result = ret == null ? 0 : ret.clone_ptr();
370 if (impl_holder.held != null) { impl_holder.held.ptrs_to.add(ret); };
373 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
374 return impl_holder.held;
378 * Gets the underlying MessageSendEventsProvider.
380 public MessageSendEventsProvider get_message_send_events_provider() {
381 MessageSendEventsProvider res = new MessageSendEventsProvider(null, bindings.LDKChannelMessageHandler_get_MessageSendEventsProvider(this.ptr));
382 res.ptrs_to.add(this);
387 * Handle an incoming `open_channel` message from the given peer.
389 public void handle_open_channel(byte[] their_node_id, org.ldk.structs.OpenChannel msg) {
390 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
391 Reference.reachabilityFence(this);
392 Reference.reachabilityFence(their_node_id);
393 Reference.reachabilityFence(msg);
394 if (this != null) { this.ptrs_to.add(msg); };
398 * Handle an incoming `open_channel2` message from the given peer.
400 public void handle_open_channel_v2(byte[] their_node_id, org.ldk.structs.OpenChannelV2 msg) {
401 bindings.ChannelMessageHandler_handle_open_channel_v2(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
402 Reference.reachabilityFence(this);
403 Reference.reachabilityFence(their_node_id);
404 Reference.reachabilityFence(msg);
405 if (this != null) { this.ptrs_to.add(msg); };
409 * Handle an incoming `accept_channel` message from the given peer.
411 public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.AcceptChannel msg) {
412 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
413 Reference.reachabilityFence(this);
414 Reference.reachabilityFence(their_node_id);
415 Reference.reachabilityFence(msg);
416 if (this != null) { this.ptrs_to.add(msg); };
420 * Handle an incoming `accept_channel2` message from the given peer.
422 public void handle_accept_channel_v2(byte[] their_node_id, org.ldk.structs.AcceptChannelV2 msg) {
423 bindings.ChannelMessageHandler_handle_accept_channel_v2(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
424 Reference.reachabilityFence(this);
425 Reference.reachabilityFence(their_node_id);
426 Reference.reachabilityFence(msg);
427 if (this != null) { this.ptrs_to.add(msg); };
431 * Handle an incoming `funding_created` message from the given peer.
433 public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
434 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
435 Reference.reachabilityFence(this);
436 Reference.reachabilityFence(their_node_id);
437 Reference.reachabilityFence(msg);
438 if (this != null) { this.ptrs_to.add(msg); };
442 * Handle an incoming `funding_signed` message from the given peer.
444 public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
445 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
446 Reference.reachabilityFence(this);
447 Reference.reachabilityFence(their_node_id);
448 Reference.reachabilityFence(msg);
449 if (this != null) { this.ptrs_to.add(msg); };
453 * Handle an incoming `channel_ready` message from the given peer.
455 public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
456 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
457 Reference.reachabilityFence(this);
458 Reference.reachabilityFence(their_node_id);
459 Reference.reachabilityFence(msg);
460 if (this != null) { this.ptrs_to.add(msg); };
464 * Handle an incoming `shutdown` message from the given peer.
466 public void handle_shutdown(byte[] their_node_id, org.ldk.structs.Shutdown msg) {
467 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
468 Reference.reachabilityFence(this);
469 Reference.reachabilityFence(their_node_id);
470 Reference.reachabilityFence(msg);
471 if (this != null) { this.ptrs_to.add(msg); };
475 * Handle an incoming `closing_signed` message from the given peer.
477 public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
478 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
479 Reference.reachabilityFence(this);
480 Reference.reachabilityFence(their_node_id);
481 Reference.reachabilityFence(msg);
482 if (this != null) { this.ptrs_to.add(msg); };
486 * Handle an incoming `tx_add_input message` from the given peer.
488 public void handle_tx_add_input(byte[] their_node_id, org.ldk.structs.TxAddInput msg) {
489 bindings.ChannelMessageHandler_handle_tx_add_input(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
490 Reference.reachabilityFence(this);
491 Reference.reachabilityFence(their_node_id);
492 Reference.reachabilityFence(msg);
493 if (this != null) { this.ptrs_to.add(msg); };
497 * Handle an incoming `tx_add_output` message from the given peer.
499 public void handle_tx_add_output(byte[] their_node_id, org.ldk.structs.TxAddOutput msg) {
500 bindings.ChannelMessageHandler_handle_tx_add_output(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
501 Reference.reachabilityFence(this);
502 Reference.reachabilityFence(their_node_id);
503 Reference.reachabilityFence(msg);
504 if (this != null) { this.ptrs_to.add(msg); };
508 * Handle an incoming `tx_remove_input` message from the given peer.
510 public void handle_tx_remove_input(byte[] their_node_id, org.ldk.structs.TxRemoveInput msg) {
511 bindings.ChannelMessageHandler_handle_tx_remove_input(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
512 Reference.reachabilityFence(this);
513 Reference.reachabilityFence(their_node_id);
514 Reference.reachabilityFence(msg);
515 if (this != null) { this.ptrs_to.add(msg); };
519 * Handle an incoming `tx_remove_output` message from the given peer.
521 public void handle_tx_remove_output(byte[] their_node_id, org.ldk.structs.TxRemoveOutput msg) {
522 bindings.ChannelMessageHandler_handle_tx_remove_output(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
523 Reference.reachabilityFence(this);
524 Reference.reachabilityFence(their_node_id);
525 Reference.reachabilityFence(msg);
526 if (this != null) { this.ptrs_to.add(msg); };
530 * Handle an incoming `tx_complete message` from the given peer.
532 public void handle_tx_complete(byte[] their_node_id, org.ldk.structs.TxComplete msg) {
533 bindings.ChannelMessageHandler_handle_tx_complete(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
534 Reference.reachabilityFence(this);
535 Reference.reachabilityFence(their_node_id);
536 Reference.reachabilityFence(msg);
537 if (this != null) { this.ptrs_to.add(msg); };
541 * Handle an incoming `tx_signatures` message from the given peer.
543 public void handle_tx_signatures(byte[] their_node_id, org.ldk.structs.TxSignatures msg) {
544 bindings.ChannelMessageHandler_handle_tx_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
545 Reference.reachabilityFence(this);
546 Reference.reachabilityFence(their_node_id);
547 Reference.reachabilityFence(msg);
548 if (this != null) { this.ptrs_to.add(msg); };
552 * Handle an incoming `tx_init_rbf` message from the given peer.
554 public void handle_tx_init_rbf(byte[] their_node_id, org.ldk.structs.TxInitRbf msg) {
555 bindings.ChannelMessageHandler_handle_tx_init_rbf(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
556 Reference.reachabilityFence(this);
557 Reference.reachabilityFence(their_node_id);
558 Reference.reachabilityFence(msg);
559 if (this != null) { this.ptrs_to.add(msg); };
563 * Handle an incoming `tx_ack_rbf` message from the given peer.
565 public void handle_tx_ack_rbf(byte[] their_node_id, org.ldk.structs.TxAckRbf msg) {
566 bindings.ChannelMessageHandler_handle_tx_ack_rbf(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
567 Reference.reachabilityFence(this);
568 Reference.reachabilityFence(their_node_id);
569 Reference.reachabilityFence(msg);
570 if (this != null) { this.ptrs_to.add(msg); };
574 * Handle an incoming `tx_abort message` from the given peer.
576 public void handle_tx_abort(byte[] their_node_id, org.ldk.structs.TxAbort msg) {
577 bindings.ChannelMessageHandler_handle_tx_abort(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
578 Reference.reachabilityFence(this);
579 Reference.reachabilityFence(their_node_id);
580 Reference.reachabilityFence(msg);
581 if (this != null) { this.ptrs_to.add(msg); };
585 * Handle an incoming `update_add_htlc` message from the given peer.
587 public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
588 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
589 Reference.reachabilityFence(this);
590 Reference.reachabilityFence(their_node_id);
591 Reference.reachabilityFence(msg);
592 if (this != null) { this.ptrs_to.add(msg); };
596 * Handle an incoming `update_fulfill_htlc` message from the given peer.
598 public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
599 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
600 Reference.reachabilityFence(this);
601 Reference.reachabilityFence(their_node_id);
602 Reference.reachabilityFence(msg);
603 if (this != null) { this.ptrs_to.add(msg); };
607 * Handle an incoming `update_fail_htlc` message from the given peer.
609 public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
610 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
611 Reference.reachabilityFence(this);
612 Reference.reachabilityFence(their_node_id);
613 Reference.reachabilityFence(msg);
614 if (this != null) { this.ptrs_to.add(msg); };
618 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
620 public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
621 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
622 Reference.reachabilityFence(this);
623 Reference.reachabilityFence(their_node_id);
624 Reference.reachabilityFence(msg);
625 if (this != null) { this.ptrs_to.add(msg); };
629 * Handle an incoming `commitment_signed` message from the given peer.
631 public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
632 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
633 Reference.reachabilityFence(this);
634 Reference.reachabilityFence(their_node_id);
635 Reference.reachabilityFence(msg);
636 if (this != null) { this.ptrs_to.add(msg); };
640 * Handle an incoming `revoke_and_ack` message from the given peer.
642 public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
643 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
644 Reference.reachabilityFence(this);
645 Reference.reachabilityFence(their_node_id);
646 Reference.reachabilityFence(msg);
647 if (this != null) { this.ptrs_to.add(msg); };
651 * Handle an incoming `update_fee` message from the given peer.
653 public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
654 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
655 Reference.reachabilityFence(this);
656 Reference.reachabilityFence(their_node_id);
657 Reference.reachabilityFence(msg);
658 if (this != null) { this.ptrs_to.add(msg); };
662 * Handle an incoming `announcement_signatures` message from the given peer.
664 public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
665 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
666 Reference.reachabilityFence(this);
667 Reference.reachabilityFence(their_node_id);
668 Reference.reachabilityFence(msg);
669 if (this != null) { this.ptrs_to.add(msg); };
673 * Indicates a connection to the peer failed/an existing connection was lost.
675 public void peer_disconnected(byte[] their_node_id) {
676 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
677 Reference.reachabilityFence(this);
678 Reference.reachabilityFence(their_node_id);
682 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
684 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
685 * with us. Implementors should be somewhat conservative about doing so, however, as other
686 * message handlers may still wish to communicate with this peer.
688 public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg, boolean inbound) {
689 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr, inbound);
690 Reference.reachabilityFence(this);
691 Reference.reachabilityFence(their_node_id);
692 Reference.reachabilityFence(msg);
693 Reference.reachabilityFence(inbound);
694 if (ret >= 0 && ret <= 4096) { return null; }
695 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
696 if (this != null) { this.ptrs_to.add(msg); };
701 * Handle an incoming `channel_reestablish` message from the given peer.
703 public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
704 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
705 Reference.reachabilityFence(this);
706 Reference.reachabilityFence(their_node_id);
707 Reference.reachabilityFence(msg);
708 if (this != null) { this.ptrs_to.add(msg); };
712 * Handle an incoming `channel_update` message from the given peer.
714 public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
715 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
716 Reference.reachabilityFence(this);
717 Reference.reachabilityFence(their_node_id);
718 Reference.reachabilityFence(msg);
719 if (this != null) { this.ptrs_to.add(msg); };
723 * Handle an incoming `error` message from the given peer.
725 public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
726 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
727 Reference.reachabilityFence(this);
728 Reference.reachabilityFence(their_node_id);
729 Reference.reachabilityFence(msg);
730 if (this != null) { this.ptrs_to.add(msg); };
734 * Gets the node feature flags which this handler itself supports. All available handlers are
735 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
736 * which are broadcasted in our [`NodeAnnouncement`] message.
738 public NodeFeatures provided_node_features() {
739 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
740 Reference.reachabilityFence(this);
741 if (ret >= 0 && ret <= 4096) { return null; }
742 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
743 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
748 * Gets the init feature flags which should be sent to the given peer. All available handlers
749 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
750 * which are sent in our [`Init`] message.
752 * Note that this method is called before [`Self::peer_connected`].
754 public InitFeatures provided_init_features(byte[] their_node_id) {
755 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
756 Reference.reachabilityFence(this);
757 Reference.reachabilityFence(their_node_id);
758 if (ret >= 0 && ret <= 4096) { return null; }
759 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
760 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
765 * Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports.
767 * If it's `None`, then no particular network chain hash compatibility will be enforced when
768 * connecting to peers.
770 public Option_CVec_ThirtyTwoBytesZZ get_genesis_hashes() {
771 long ret = bindings.ChannelMessageHandler_get_genesis_hashes(this.ptr);
772 Reference.reachabilityFence(this);
773 if (ret >= 0 && ret <= 4096) { return null; }
774 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
775 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };