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 `splice` message from the given peer.
87 void handle_splice(byte[] their_node_id, Splice msg);
89 * Handle an incoming `splice_ack` message from the given peer.
91 void handle_splice_ack(byte[] their_node_id, SpliceAck msg);
93 * Handle an incoming `splice_locked` message from the given peer.
95 void handle_splice_locked(byte[] their_node_id, SpliceLocked msg);
97 * Handle an incoming `tx_add_input message` from the given peer.
99 void handle_tx_add_input(byte[] their_node_id, TxAddInput msg);
101 * Handle an incoming `tx_add_output` message from the given peer.
103 void handle_tx_add_output(byte[] their_node_id, TxAddOutput msg);
105 * Handle an incoming `tx_remove_input` message from the given peer.
107 void handle_tx_remove_input(byte[] their_node_id, TxRemoveInput msg);
109 * Handle an incoming `tx_remove_output` message from the given peer.
111 void handle_tx_remove_output(byte[] their_node_id, TxRemoveOutput msg);
113 * Handle an incoming `tx_complete message` from the given peer.
115 void handle_tx_complete(byte[] their_node_id, TxComplete msg);
117 * Handle an incoming `tx_signatures` message from the given peer.
119 void handle_tx_signatures(byte[] their_node_id, TxSignatures msg);
121 * Handle an incoming `tx_init_rbf` message from the given peer.
123 void handle_tx_init_rbf(byte[] their_node_id, TxInitRbf msg);
125 * Handle an incoming `tx_ack_rbf` message from the given peer.
127 void handle_tx_ack_rbf(byte[] their_node_id, TxAckRbf msg);
129 * Handle an incoming `tx_abort message` from the given peer.
131 void handle_tx_abort(byte[] their_node_id, TxAbort msg);
133 * Handle an incoming `update_add_htlc` message from the given peer.
135 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
137 * Handle an incoming `update_fulfill_htlc` message from the given peer.
139 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
141 * Handle an incoming `update_fail_htlc` message from the given peer.
143 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
145 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
147 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
149 * Handle an incoming `commitment_signed` message from the given peer.
151 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
153 * Handle an incoming `revoke_and_ack` message from the given peer.
155 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
157 * Handle an incoming `update_fee` message from the given peer.
159 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
161 * Handle an incoming `announcement_signatures` message from the given peer.
163 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
165 * Indicates a connection to the peer failed/an existing connection was lost.
167 void peer_disconnected(byte[] their_node_id);
169 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
171 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
172 * with us. Implementors should be somewhat conservative about doing so, however, as other
173 * message handlers may still wish to communicate with this peer.
175 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, boolean inbound);
177 * Handle an incoming `channel_reestablish` message from the given peer.
179 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
181 * Handle an incoming `channel_update` message from the given peer.
183 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
185 * Handle an incoming `error` message from the given peer.
187 void handle_error(byte[] their_node_id, ErrorMessage msg);
189 * Gets the node feature flags which this handler itself supports. All available handlers are
190 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
191 * which are broadcasted in our [`NodeAnnouncement`] message.
193 NodeFeatures provided_node_features();
195 * Gets the init feature flags which should be sent to the given peer. All available handlers
196 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
197 * which are sent in our [`Init`] message.
199 * Note that this method is called before [`Self::peer_connected`].
201 InitFeatures provided_init_features(byte[] their_node_id);
203 * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
205 * If it's `None`, then no particular network chain hash compatibility will be enforced when
206 * connecting to peers.
208 Option_CVec_ThirtyTwoBytesZZ get_chain_hashes();
210 private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
211 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
212 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
213 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
214 @Override public void handle_open_channel(byte[] their_node_id, long msg) {
215 org.ldk.structs.OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannel(null, msg); }
216 arg.handle_open_channel(their_node_id, msg_hu_conv);
217 Reference.reachabilityFence(arg);
219 @Override public void handle_open_channel_v2(byte[] their_node_id, long msg) {
220 org.ldk.structs.OpenChannelV2 msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannelV2(null, msg); }
221 arg.handle_open_channel_v2(their_node_id, msg_hu_conv);
222 Reference.reachabilityFence(arg);
224 @Override public void handle_accept_channel(byte[] their_node_id, long msg) {
225 org.ldk.structs.AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannel(null, msg); }
226 arg.handle_accept_channel(their_node_id, msg_hu_conv);
227 Reference.reachabilityFence(arg);
229 @Override public void handle_accept_channel_v2(byte[] their_node_id, long msg) {
230 org.ldk.structs.AcceptChannelV2 msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannelV2(null, msg); }
231 arg.handle_accept_channel_v2(their_node_id, msg_hu_conv);
232 Reference.reachabilityFence(arg);
234 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
235 org.ldk.structs.FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingCreated(null, msg); }
236 arg.handle_funding_created(their_node_id, msg_hu_conv);
237 Reference.reachabilityFence(arg);
239 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
240 org.ldk.structs.FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingSigned(null, msg); }
241 arg.handle_funding_signed(their_node_id, msg_hu_conv);
242 Reference.reachabilityFence(arg);
244 @Override public void handle_channel_ready(byte[] their_node_id, long msg) {
245 org.ldk.structs.ChannelReady msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReady(null, msg); }
246 arg.handle_channel_ready(their_node_id, msg_hu_conv);
247 Reference.reachabilityFence(arg);
249 @Override public void handle_shutdown(byte[] their_node_id, long msg) {
250 org.ldk.structs.Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Shutdown(null, msg); }
251 arg.handle_shutdown(their_node_id, msg_hu_conv);
252 Reference.reachabilityFence(arg);
254 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
255 org.ldk.structs.ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ClosingSigned(null, msg); }
256 arg.handle_closing_signed(their_node_id, msg_hu_conv);
257 Reference.reachabilityFence(arg);
259 @Override public void handle_stfu(byte[] their_node_id, long msg) {
260 org.ldk.structs.Stfu msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Stfu(null, msg); }
261 arg.handle_stfu(their_node_id, msg_hu_conv);
262 Reference.reachabilityFence(arg);
264 @Override public void handle_splice(byte[] their_node_id, long msg) {
265 org.ldk.structs.Splice msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Splice(null, msg); }
266 arg.handle_splice(their_node_id, msg_hu_conv);
267 Reference.reachabilityFence(arg);
269 @Override public void handle_splice_ack(byte[] their_node_id, long msg) {
270 org.ldk.structs.SpliceAck msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.SpliceAck(null, msg); }
271 arg.handle_splice_ack(their_node_id, msg_hu_conv);
272 Reference.reachabilityFence(arg);
274 @Override public void handle_splice_locked(byte[] their_node_id, long msg) {
275 org.ldk.structs.SpliceLocked msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.SpliceLocked(null, msg); }
276 arg.handle_splice_locked(their_node_id, msg_hu_conv);
277 Reference.reachabilityFence(arg);
279 @Override public void handle_tx_add_input(byte[] their_node_id, long msg) {
280 org.ldk.structs.TxAddInput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAddInput(null, msg); }
281 arg.handle_tx_add_input(their_node_id, msg_hu_conv);
282 Reference.reachabilityFence(arg);
284 @Override public void handle_tx_add_output(byte[] their_node_id, long msg) {
285 org.ldk.structs.TxAddOutput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAddOutput(null, msg); }
286 arg.handle_tx_add_output(their_node_id, msg_hu_conv);
287 Reference.reachabilityFence(arg);
289 @Override public void handle_tx_remove_input(byte[] their_node_id, long msg) {
290 org.ldk.structs.TxRemoveInput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxRemoveInput(null, msg); }
291 arg.handle_tx_remove_input(their_node_id, msg_hu_conv);
292 Reference.reachabilityFence(arg);
294 @Override public void handle_tx_remove_output(byte[] their_node_id, long msg) {
295 org.ldk.structs.TxRemoveOutput msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxRemoveOutput(null, msg); }
296 arg.handle_tx_remove_output(their_node_id, msg_hu_conv);
297 Reference.reachabilityFence(arg);
299 @Override public void handle_tx_complete(byte[] their_node_id, long msg) {
300 org.ldk.structs.TxComplete msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxComplete(null, msg); }
301 arg.handle_tx_complete(their_node_id, msg_hu_conv);
302 Reference.reachabilityFence(arg);
304 @Override public void handle_tx_signatures(byte[] their_node_id, long msg) {
305 org.ldk.structs.TxSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxSignatures(null, msg); }
306 arg.handle_tx_signatures(their_node_id, msg_hu_conv);
307 Reference.reachabilityFence(arg);
309 @Override public void handle_tx_init_rbf(byte[] their_node_id, long msg) {
310 org.ldk.structs.TxInitRbf msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxInitRbf(null, msg); }
311 arg.handle_tx_init_rbf(their_node_id, msg_hu_conv);
312 Reference.reachabilityFence(arg);
314 @Override public void handle_tx_ack_rbf(byte[] their_node_id, long msg) {
315 org.ldk.structs.TxAckRbf msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAckRbf(null, msg); }
316 arg.handle_tx_ack_rbf(their_node_id, msg_hu_conv);
317 Reference.reachabilityFence(arg);
319 @Override public void handle_tx_abort(byte[] their_node_id, long msg) {
320 org.ldk.structs.TxAbort msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.TxAbort(null, msg); }
321 arg.handle_tx_abort(their_node_id, msg_hu_conv);
322 Reference.reachabilityFence(arg);
324 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
325 org.ldk.structs.UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, msg); }
326 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
327 Reference.reachabilityFence(arg);
329 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
330 org.ldk.structs.UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, msg); }
331 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
332 Reference.reachabilityFence(arg);
334 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
335 org.ldk.structs.UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, msg); }
336 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
337 Reference.reachabilityFence(arg);
339 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
340 org.ldk.structs.UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, msg); }
341 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
342 Reference.reachabilityFence(arg);
344 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
345 org.ldk.structs.CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, msg); }
346 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
347 Reference.reachabilityFence(arg);
349 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
350 org.ldk.structs.RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, msg); }
351 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
352 Reference.reachabilityFence(arg);
354 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
355 org.ldk.structs.UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFee(null, msg); }
356 arg.handle_update_fee(their_node_id, msg_hu_conv);
357 Reference.reachabilityFence(arg);
359 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
360 org.ldk.structs.AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, msg); }
361 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
362 Reference.reachabilityFence(arg);
364 @Override public void peer_disconnected(byte[] their_node_id) {
365 arg.peer_disconnected(their_node_id);
366 Reference.reachabilityFence(arg);
368 @Override public long peer_connected(byte[] their_node_id, long msg, boolean inbound) {
369 org.ldk.structs.Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Init(null, msg); }
370 Result_NoneNoneZ ret = arg.peer_connected(their_node_id, msg_hu_conv, inbound);
371 Reference.reachabilityFence(arg);
372 long result = ret == null ? 0 : ret.clone_ptr();
375 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
376 org.ldk.structs.ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, msg); }
377 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
378 Reference.reachabilityFence(arg);
380 @Override public void handle_channel_update(byte[] their_node_id, long msg) {
381 org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); }
382 arg.handle_channel_update(their_node_id, msg_hu_conv);
383 Reference.reachabilityFence(arg);
385 @Override public void handle_error(byte[] their_node_id, long msg) {
386 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
387 arg.handle_error(their_node_id, msg_hu_conv);
388 Reference.reachabilityFence(arg);
390 @Override public long provided_node_features() {
391 NodeFeatures ret = arg.provided_node_features();
392 Reference.reachabilityFence(arg);
393 long result = ret == null ? 0 : ret.clone_ptr();
396 @Override public long provided_init_features(byte[] their_node_id) {
397 InitFeatures ret = arg.provided_init_features(their_node_id);
398 Reference.reachabilityFence(arg);
399 long result = ret == null ? 0 : ret.clone_ptr();
402 @Override public long get_chain_hashes() {
403 Option_CVec_ThirtyTwoBytesZZ ret = arg.get_chain_hashes();
404 Reference.reachabilityFence(arg);
405 long result = ret == null ? 0 : ret.clone_ptr();
406 if (impl_holder.held != null) { impl_holder.held.ptrs_to.add(ret); };
409 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
410 return impl_holder.held;
414 * Gets the underlying MessageSendEventsProvider.
416 public MessageSendEventsProvider get_message_send_events_provider() {
417 MessageSendEventsProvider res = new MessageSendEventsProvider(null, bindings.LDKChannelMessageHandler_get_MessageSendEventsProvider(this.ptr));
418 res.ptrs_to.add(this);
423 * Handle an incoming `open_channel` message from the given peer.
425 public void handle_open_channel(byte[] their_node_id, org.ldk.structs.OpenChannel msg) {
426 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
427 Reference.reachabilityFence(this);
428 Reference.reachabilityFence(their_node_id);
429 Reference.reachabilityFence(msg);
430 if (this != null) { this.ptrs_to.add(msg); };
434 * Handle an incoming `open_channel2` message from the given peer.
436 public void handle_open_channel_v2(byte[] their_node_id, org.ldk.structs.OpenChannelV2 msg) {
437 bindings.ChannelMessageHandler_handle_open_channel_v2(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
438 Reference.reachabilityFence(this);
439 Reference.reachabilityFence(their_node_id);
440 Reference.reachabilityFence(msg);
441 if (this != null) { this.ptrs_to.add(msg); };
445 * Handle an incoming `accept_channel` message from the given peer.
447 public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.AcceptChannel msg) {
448 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
449 Reference.reachabilityFence(this);
450 Reference.reachabilityFence(their_node_id);
451 Reference.reachabilityFence(msg);
452 if (this != null) { this.ptrs_to.add(msg); };
456 * Handle an incoming `accept_channel2` message from the given peer.
458 public void handle_accept_channel_v2(byte[] their_node_id, org.ldk.structs.AcceptChannelV2 msg) {
459 bindings.ChannelMessageHandler_handle_accept_channel_v2(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
460 Reference.reachabilityFence(this);
461 Reference.reachabilityFence(their_node_id);
462 Reference.reachabilityFence(msg);
463 if (this != null) { this.ptrs_to.add(msg); };
467 * Handle an incoming `funding_created` message from the given peer.
469 public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
470 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
471 Reference.reachabilityFence(this);
472 Reference.reachabilityFence(their_node_id);
473 Reference.reachabilityFence(msg);
474 if (this != null) { this.ptrs_to.add(msg); };
478 * Handle an incoming `funding_signed` message from the given peer.
480 public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
481 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
482 Reference.reachabilityFence(this);
483 Reference.reachabilityFence(their_node_id);
484 Reference.reachabilityFence(msg);
485 if (this != null) { this.ptrs_to.add(msg); };
489 * Handle an incoming `channel_ready` message from the given peer.
491 public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
492 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
493 Reference.reachabilityFence(this);
494 Reference.reachabilityFence(their_node_id);
495 Reference.reachabilityFence(msg);
496 if (this != null) { this.ptrs_to.add(msg); };
500 * Handle an incoming `shutdown` message from the given peer.
502 public void handle_shutdown(byte[] their_node_id, org.ldk.structs.Shutdown msg) {
503 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
504 Reference.reachabilityFence(this);
505 Reference.reachabilityFence(their_node_id);
506 Reference.reachabilityFence(msg);
507 if (this != null) { this.ptrs_to.add(msg); };
511 * Handle an incoming `closing_signed` message from the given peer.
513 public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
514 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
515 Reference.reachabilityFence(this);
516 Reference.reachabilityFence(their_node_id);
517 Reference.reachabilityFence(msg);
518 if (this != null) { this.ptrs_to.add(msg); };
522 * Handle an incoming `stfu` message from the given peer.
524 public void handle_stfu(byte[] their_node_id, org.ldk.structs.Stfu msg) {
525 bindings.ChannelMessageHandler_handle_stfu(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
526 Reference.reachabilityFence(this);
527 Reference.reachabilityFence(their_node_id);
528 Reference.reachabilityFence(msg);
529 if (this != null) { this.ptrs_to.add(msg); };
533 * Handle an incoming `splice` message from the given peer.
535 public void handle_splice(byte[] their_node_id, org.ldk.structs.Splice msg) {
536 bindings.ChannelMessageHandler_handle_splice(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
537 Reference.reachabilityFence(this);
538 Reference.reachabilityFence(their_node_id);
539 Reference.reachabilityFence(msg);
540 if (this != null) { this.ptrs_to.add(msg); };
544 * Handle an incoming `splice_ack` message from the given peer.
546 public void handle_splice_ack(byte[] their_node_id, org.ldk.structs.SpliceAck msg) {
547 bindings.ChannelMessageHandler_handle_splice_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
548 Reference.reachabilityFence(this);
549 Reference.reachabilityFence(their_node_id);
550 Reference.reachabilityFence(msg);
551 if (this != null) { this.ptrs_to.add(msg); };
555 * Handle an incoming `splice_locked` message from the given peer.
557 public void handle_splice_locked(byte[] their_node_id, org.ldk.structs.SpliceLocked msg) {
558 bindings.ChannelMessageHandler_handle_splice_locked(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
559 Reference.reachabilityFence(this);
560 Reference.reachabilityFence(their_node_id);
561 Reference.reachabilityFence(msg);
562 if (this != null) { this.ptrs_to.add(msg); };
566 * Handle an incoming `tx_add_input message` from the given peer.
568 public void handle_tx_add_input(byte[] their_node_id, org.ldk.structs.TxAddInput msg) {
569 bindings.ChannelMessageHandler_handle_tx_add_input(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
570 Reference.reachabilityFence(this);
571 Reference.reachabilityFence(their_node_id);
572 Reference.reachabilityFence(msg);
573 if (this != null) { this.ptrs_to.add(msg); };
577 * Handle an incoming `tx_add_output` message from the given peer.
579 public void handle_tx_add_output(byte[] their_node_id, org.ldk.structs.TxAddOutput msg) {
580 bindings.ChannelMessageHandler_handle_tx_add_output(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
581 Reference.reachabilityFence(this);
582 Reference.reachabilityFence(their_node_id);
583 Reference.reachabilityFence(msg);
584 if (this != null) { this.ptrs_to.add(msg); };
588 * Handle an incoming `tx_remove_input` message from the given peer.
590 public void handle_tx_remove_input(byte[] their_node_id, org.ldk.structs.TxRemoveInput msg) {
591 bindings.ChannelMessageHandler_handle_tx_remove_input(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
592 Reference.reachabilityFence(this);
593 Reference.reachabilityFence(their_node_id);
594 Reference.reachabilityFence(msg);
595 if (this != null) { this.ptrs_to.add(msg); };
599 * Handle an incoming `tx_remove_output` message from the given peer.
601 public void handle_tx_remove_output(byte[] their_node_id, org.ldk.structs.TxRemoveOutput msg) {
602 bindings.ChannelMessageHandler_handle_tx_remove_output(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
603 Reference.reachabilityFence(this);
604 Reference.reachabilityFence(their_node_id);
605 Reference.reachabilityFence(msg);
606 if (this != null) { this.ptrs_to.add(msg); };
610 * Handle an incoming `tx_complete message` from the given peer.
612 public void handle_tx_complete(byte[] their_node_id, org.ldk.structs.TxComplete msg) {
613 bindings.ChannelMessageHandler_handle_tx_complete(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
614 Reference.reachabilityFence(this);
615 Reference.reachabilityFence(their_node_id);
616 Reference.reachabilityFence(msg);
617 if (this != null) { this.ptrs_to.add(msg); };
621 * Handle an incoming `tx_signatures` message from the given peer.
623 public void handle_tx_signatures(byte[] their_node_id, org.ldk.structs.TxSignatures msg) {
624 bindings.ChannelMessageHandler_handle_tx_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
625 Reference.reachabilityFence(this);
626 Reference.reachabilityFence(their_node_id);
627 Reference.reachabilityFence(msg);
628 if (this != null) { this.ptrs_to.add(msg); };
632 * Handle an incoming `tx_init_rbf` message from the given peer.
634 public void handle_tx_init_rbf(byte[] their_node_id, org.ldk.structs.TxInitRbf msg) {
635 bindings.ChannelMessageHandler_handle_tx_init_rbf(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
636 Reference.reachabilityFence(this);
637 Reference.reachabilityFence(their_node_id);
638 Reference.reachabilityFence(msg);
639 if (this != null) { this.ptrs_to.add(msg); };
643 * Handle an incoming `tx_ack_rbf` message from the given peer.
645 public void handle_tx_ack_rbf(byte[] their_node_id, org.ldk.structs.TxAckRbf msg) {
646 bindings.ChannelMessageHandler_handle_tx_ack_rbf(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
647 Reference.reachabilityFence(this);
648 Reference.reachabilityFence(their_node_id);
649 Reference.reachabilityFence(msg);
650 if (this != null) { this.ptrs_to.add(msg); };
654 * Handle an incoming `tx_abort message` from the given peer.
656 public void handle_tx_abort(byte[] their_node_id, org.ldk.structs.TxAbort msg) {
657 bindings.ChannelMessageHandler_handle_tx_abort(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
658 Reference.reachabilityFence(this);
659 Reference.reachabilityFence(their_node_id);
660 Reference.reachabilityFence(msg);
661 if (this != null) { this.ptrs_to.add(msg); };
665 * Handle an incoming `update_add_htlc` message from the given peer.
667 public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
668 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
669 Reference.reachabilityFence(this);
670 Reference.reachabilityFence(their_node_id);
671 Reference.reachabilityFence(msg);
672 if (this != null) { this.ptrs_to.add(msg); };
676 * Handle an incoming `update_fulfill_htlc` message from the given peer.
678 public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
679 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
680 Reference.reachabilityFence(this);
681 Reference.reachabilityFence(their_node_id);
682 Reference.reachabilityFence(msg);
683 if (this != null) { this.ptrs_to.add(msg); };
687 * Handle an incoming `update_fail_htlc` message from the given peer.
689 public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
690 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
691 Reference.reachabilityFence(this);
692 Reference.reachabilityFence(their_node_id);
693 Reference.reachabilityFence(msg);
694 if (this != null) { this.ptrs_to.add(msg); };
698 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
700 public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
701 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
702 Reference.reachabilityFence(this);
703 Reference.reachabilityFence(their_node_id);
704 Reference.reachabilityFence(msg);
705 if (this != null) { this.ptrs_to.add(msg); };
709 * Handle an incoming `commitment_signed` message from the given peer.
711 public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
712 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
713 Reference.reachabilityFence(this);
714 Reference.reachabilityFence(their_node_id);
715 Reference.reachabilityFence(msg);
716 if (this != null) { this.ptrs_to.add(msg); };
720 * Handle an incoming `revoke_and_ack` message from the given peer.
722 public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
723 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
724 Reference.reachabilityFence(this);
725 Reference.reachabilityFence(their_node_id);
726 Reference.reachabilityFence(msg);
727 if (this != null) { this.ptrs_to.add(msg); };
731 * Handle an incoming `update_fee` message from the given peer.
733 public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
734 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
735 Reference.reachabilityFence(this);
736 Reference.reachabilityFence(their_node_id);
737 Reference.reachabilityFence(msg);
738 if (this != null) { this.ptrs_to.add(msg); };
742 * Handle an incoming `announcement_signatures` message from the given peer.
744 public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
745 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
746 Reference.reachabilityFence(this);
747 Reference.reachabilityFence(their_node_id);
748 Reference.reachabilityFence(msg);
749 if (this != null) { this.ptrs_to.add(msg); };
753 * Indicates a connection to the peer failed/an existing connection was lost.
755 public void peer_disconnected(byte[] their_node_id) {
756 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
757 Reference.reachabilityFence(this);
758 Reference.reachabilityFence(their_node_id);
762 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
764 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
765 * with us. Implementors should be somewhat conservative about doing so, however, as other
766 * message handlers may still wish to communicate with this peer.
768 public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg, boolean inbound) {
769 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr, inbound);
770 Reference.reachabilityFence(this);
771 Reference.reachabilityFence(their_node_id);
772 Reference.reachabilityFence(msg);
773 Reference.reachabilityFence(inbound);
774 if (ret >= 0 && ret <= 4096) { return null; }
775 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
776 if (this != null) { this.ptrs_to.add(msg); };
781 * Handle an incoming `channel_reestablish` message from the given peer.
783 public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
784 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
785 Reference.reachabilityFence(this);
786 Reference.reachabilityFence(their_node_id);
787 Reference.reachabilityFence(msg);
788 if (this != null) { this.ptrs_to.add(msg); };
792 * Handle an incoming `channel_update` message from the given peer.
794 public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
795 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
796 Reference.reachabilityFence(this);
797 Reference.reachabilityFence(their_node_id);
798 Reference.reachabilityFence(msg);
799 if (this != null) { this.ptrs_to.add(msg); };
803 * Handle an incoming `error` message from the given peer.
805 public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
806 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
807 Reference.reachabilityFence(this);
808 Reference.reachabilityFence(their_node_id);
809 Reference.reachabilityFence(msg);
810 if (this != null) { this.ptrs_to.add(msg); };
814 * Gets the node feature flags which this handler itself supports. All available handlers are
815 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
816 * which are broadcasted in our [`NodeAnnouncement`] message.
818 public NodeFeatures provided_node_features() {
819 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
820 Reference.reachabilityFence(this);
821 if (ret >= 0 && ret <= 4096) { return null; }
822 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
823 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
828 * Gets the init feature flags which should be sent to the given peer. All available handlers
829 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
830 * which are sent in our [`Init`] message.
832 * Note that this method is called before [`Self::peer_connected`].
834 public InitFeatures provided_init_features(byte[] their_node_id) {
835 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
836 Reference.reachabilityFence(this);
837 Reference.reachabilityFence(their_node_id);
838 if (ret >= 0 && ret <= 4096) { return null; }
839 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
840 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
845 * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
847 * If it's `None`, then no particular network chain hash compatibility will be enforced when
848 * connecting to peers.
850 public Option_CVec_ThirtyTwoBytesZZ get_chain_hashes() {
851 long ret = bindings.ChannelMessageHandler_get_chain_hashes(this.ptr);
852 Reference.reachabilityFence(this);
853 if (ret >= 0 && ret <= 4096) { return null; }
854 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
855 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };