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 `stfu` message from the given peer.
83 void handle_stfu(byte[] their_node_id, Stfu msg);
85 * Handle an incoming `tx_add_input message` from the given peer.
87 void handle_tx_add_input(byte[] their_node_id, TxAddInput msg);
89 * Handle an incoming `tx_add_output` message from the given peer.
91 void handle_tx_add_output(byte[] their_node_id, TxAddOutput msg);
93 * Handle an incoming `tx_remove_input` message from the given peer.
95 void handle_tx_remove_input(byte[] their_node_id, TxRemoveInput msg);
97 * Handle an incoming `tx_remove_output` message from the given peer.
99 void handle_tx_remove_output(byte[] their_node_id, TxRemoveOutput msg);
101 * Handle an incoming `tx_complete message` from the given peer.
103 void handle_tx_complete(byte[] their_node_id, TxComplete msg);
105 * Handle an incoming `tx_signatures` message from the given peer.
107 void handle_tx_signatures(byte[] their_node_id, TxSignatures msg);
109 * Handle an incoming `tx_init_rbf` message from the given peer.
111 void handle_tx_init_rbf(byte[] their_node_id, TxInitRbf msg);
113 * Handle an incoming `tx_ack_rbf` message from the given peer.
115 void handle_tx_ack_rbf(byte[] their_node_id, TxAckRbf msg);
117 * Handle an incoming `tx_abort message` from the given peer.
119 void handle_tx_abort(byte[] their_node_id, TxAbort msg);
121 * Handle an incoming `update_add_htlc` message from the given peer.
123 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
125 * Handle an incoming `update_fulfill_htlc` message from the given peer.
127 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
129 * Handle an incoming `update_fail_htlc` message from the given peer.
131 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
133 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
135 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
137 * Handle an incoming `commitment_signed` message from the given peer.
139 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
141 * Handle an incoming `revoke_and_ack` message from the given peer.
143 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
145 * Handle an incoming `update_fee` message from the given peer.
147 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
149 * Handle an incoming `announcement_signatures` message from the given peer.
151 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
153 * Indicates a connection to the peer failed/an existing connection was lost.
155 void peer_disconnected(byte[] their_node_id);
157 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
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.
163 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, boolean inbound);
165 * Handle an incoming `channel_reestablish` message from the given peer.
167 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
169 * Handle an incoming `channel_update` message from the given peer.
171 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
173 * Handle an incoming `error` message from the given peer.
175 void handle_error(byte[] their_node_id, ErrorMessage msg);
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.
181 NodeFeatures provided_node_features();
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.
187 * Note that this method is called before [`Self::peer_connected`].
189 InitFeatures provided_init_features(byte[] their_node_id);
191 * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
193 * If it's `None`, then no particular network chain hash compatibility will be enforced when
194 * connecting to peers.
196 Option_CVec_ThirtyTwoBytesZZ get_chain_hashes();
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
337 @Override public void peer_disconnected(byte[] their_node_id) {
338 arg.peer_disconnected(their_node_id);
339 Reference.reachabilityFence(arg);
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();
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);
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);
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);
363 @Override public long provided_node_features() {
364 NodeFeatures ret = arg.provided_node_features();
365 Reference.reachabilityFence(arg);
366 long result = ret.clone_ptr();
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();
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); };
382 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
383 return impl_holder.held;
387 * Gets the underlying MessageSendEventsProvider.
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);
396 * Handle an incoming `open_channel` message from the given peer.
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); };
407 * Handle an incoming `open_channel2` message from the given peer.
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); };
418 * Handle an incoming `accept_channel` message from the given peer.
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); };
429 * Handle an incoming `accept_channel2` message from the given peer.
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); };
440 * Handle an incoming `funding_created` message from the given peer.
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); };
451 * Handle an incoming `funding_signed` message from the given peer.
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); };
462 * Handle an incoming `channel_ready` message from the given peer.
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); };
473 * Handle an incoming `shutdown` message from the given peer.
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); };
484 * Handle an incoming `closing_signed` message from the given peer.
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); };
495 * Handle an incoming `stfu` message from the given peer.
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); };
506 * Handle an incoming `tx_add_input message` from the given peer.
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); };
517 * Handle an incoming `tx_add_output` message from the given peer.
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); };
528 * Handle an incoming `tx_remove_input` message from the given peer.
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); };
539 * Handle an incoming `tx_remove_output` message from the given peer.
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); };
550 * Handle an incoming `tx_complete message` from the given peer.
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); };
561 * Handle an incoming `tx_signatures` message from the given peer.
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); };
572 * Handle an incoming `tx_init_rbf` message from the given peer.
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); };
583 * Handle an incoming `tx_ack_rbf` message from the given peer.
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); };
594 * Handle an incoming `tx_abort message` from the given peer.
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); };
605 * Handle an incoming `update_add_htlc` message from the given peer.
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); };
616 * Handle an incoming `update_fulfill_htlc` message from the given peer.
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); };
627 * Handle an incoming `update_fail_htlc` message from the given peer.
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); };
638 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
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); };
649 * Handle an incoming `commitment_signed` message from the given peer.
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); };
660 * Handle an incoming `revoke_and_ack` message from the given peer.
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); };
671 * Handle an incoming `update_fee` message from the given peer.
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); };
682 * Handle an incoming `announcement_signatures` message from the given peer.
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); };
693 * Indicates a connection to the peer failed/an existing connection was lost.
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);
702 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
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.
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); };
721 * Handle an incoming `channel_reestablish` message from the given peer.
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); };
732 * Handle an incoming `channel_update` message from the given peer.
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); };
743 * Handle an incoming `error` message from the given peer.
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); };
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.
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); };
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.
772 * Note that this method is called before [`Self::peer_connected`].
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); };
785 * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
787 * If it's `None`, then no particular network chain hash compatibility will be enforced when
788 * connecting to peers.
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); };