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 `accept_channel` message from the given peer.
51 void handle_accept_channel(byte[] their_node_id, AcceptChannel msg);
53 * Handle an incoming `funding_created` message from the given peer.
55 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
57 * Handle an incoming `funding_signed` message from the given peer.
59 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
61 * Handle an incoming `channel_ready` message from the given peer.
63 void handle_channel_ready(byte[] their_node_id, ChannelReady msg);
65 * Handle an incoming `shutdown` message from the given peer.
67 void handle_shutdown(byte[] their_node_id, Shutdown msg);
69 * Handle an incoming `closing_signed` message from the given peer.
71 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
73 * Handle an incoming `update_add_htlc` message from the given peer.
75 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
77 * Handle an incoming `update_fulfill_htlc` message from the given peer.
79 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
81 * Handle an incoming `update_fail_htlc` message from the given peer.
83 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
85 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
87 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
89 * Handle an incoming `commitment_signed` message from the given peer.
91 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
93 * Handle an incoming `revoke_and_ack` message from the given peer.
95 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
97 * Handle an incoming `update_fee` message from the given peer.
99 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
101 * Handle an incoming `announcement_signatures` message from the given peer.
103 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
105 * Indicates a connection to the peer failed/an existing connection was lost.
107 void peer_disconnected(byte[] their_node_id);
109 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
111 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
112 * with us. Implementors should be somewhat conservative about doing so, however, as other
113 * message handlers may still wish to communicate with this peer.
115 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, boolean inbound);
117 * Handle an incoming `channel_reestablish` message from the given peer.
119 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
121 * Handle an incoming `channel_update` message from the given peer.
123 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
125 * Handle an incoming `error` message from the given peer.
127 void handle_error(byte[] their_node_id, ErrorMessage msg);
129 * Gets the node feature flags which this handler itself supports. All available handlers are
130 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
131 * which are broadcasted in our [`NodeAnnouncement`] message.
133 NodeFeatures provided_node_features();
135 * Gets the init feature flags which should be sent to the given peer. All available handlers
136 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
137 * which are sent in our [`Init`] message.
139 * Note that this method is called before [`Self::peer_connected`].
141 InitFeatures provided_init_features(byte[] their_node_id);
143 private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
144 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
145 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
146 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
147 @Override public void handle_open_channel(byte[] their_node_id, long msg) {
148 org.ldk.structs.OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannel(null, msg); }
149 arg.handle_open_channel(their_node_id, msg_hu_conv);
150 Reference.reachabilityFence(arg);
152 @Override public void handle_accept_channel(byte[] their_node_id, long msg) {
153 org.ldk.structs.AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannel(null, msg); }
154 arg.handle_accept_channel(their_node_id, msg_hu_conv);
155 Reference.reachabilityFence(arg);
157 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
158 org.ldk.structs.FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingCreated(null, msg); }
159 arg.handle_funding_created(their_node_id, msg_hu_conv);
160 Reference.reachabilityFence(arg);
162 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
163 org.ldk.structs.FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingSigned(null, msg); }
164 arg.handle_funding_signed(their_node_id, msg_hu_conv);
165 Reference.reachabilityFence(arg);
167 @Override public void handle_channel_ready(byte[] their_node_id, long msg) {
168 org.ldk.structs.ChannelReady msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReady(null, msg); }
169 arg.handle_channel_ready(their_node_id, msg_hu_conv);
170 Reference.reachabilityFence(arg);
172 @Override public void handle_shutdown(byte[] their_node_id, long msg) {
173 org.ldk.structs.Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Shutdown(null, msg); }
174 arg.handle_shutdown(their_node_id, msg_hu_conv);
175 Reference.reachabilityFence(arg);
177 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
178 org.ldk.structs.ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ClosingSigned(null, msg); }
179 arg.handle_closing_signed(their_node_id, msg_hu_conv);
180 Reference.reachabilityFence(arg);
182 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
183 org.ldk.structs.UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, msg); }
184 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
185 Reference.reachabilityFence(arg);
187 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
188 org.ldk.structs.UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, msg); }
189 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
190 Reference.reachabilityFence(arg);
192 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
193 org.ldk.structs.UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, msg); }
194 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
195 Reference.reachabilityFence(arg);
197 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
198 org.ldk.structs.UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, msg); }
199 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
200 Reference.reachabilityFence(arg);
202 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
203 org.ldk.structs.CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, msg); }
204 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
205 Reference.reachabilityFence(arg);
207 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
208 org.ldk.structs.RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, msg); }
209 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
210 Reference.reachabilityFence(arg);
212 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
213 org.ldk.structs.UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFee(null, msg); }
214 arg.handle_update_fee(their_node_id, msg_hu_conv);
215 Reference.reachabilityFence(arg);
217 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
218 org.ldk.structs.AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, msg); }
219 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
220 Reference.reachabilityFence(arg);
222 @Override public void peer_disconnected(byte[] their_node_id) {
223 arg.peer_disconnected(their_node_id);
224 Reference.reachabilityFence(arg);
226 @Override public long peer_connected(byte[] their_node_id, long msg, boolean inbound) {
227 org.ldk.structs.Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Init(null, msg); }
228 Result_NoneNoneZ ret = arg.peer_connected(their_node_id, msg_hu_conv, inbound);
229 Reference.reachabilityFence(arg);
230 long result = ret == null ? 0 : ret.clone_ptr();
233 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
234 org.ldk.structs.ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, msg); }
235 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
236 Reference.reachabilityFence(arg);
238 @Override public void handle_channel_update(byte[] their_node_id, long msg) {
239 org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); }
240 arg.handle_channel_update(their_node_id, msg_hu_conv);
241 Reference.reachabilityFence(arg);
243 @Override public void handle_error(byte[] their_node_id, long msg) {
244 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
245 arg.handle_error(their_node_id, msg_hu_conv);
246 Reference.reachabilityFence(arg);
248 @Override public long provided_node_features() {
249 NodeFeatures ret = arg.provided_node_features();
250 Reference.reachabilityFence(arg);
251 long result = ret == null ? 0 : ret.clone_ptr();
254 @Override public long provided_init_features(byte[] their_node_id) {
255 InitFeatures ret = arg.provided_init_features(their_node_id);
256 Reference.reachabilityFence(arg);
257 long result = ret == null ? 0 : ret.clone_ptr();
260 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
261 return impl_holder.held;
265 * Gets the underlying MessageSendEventsProvider.
267 public MessageSendEventsProvider get_message_send_events_provider() {
268 MessageSendEventsProvider res = new MessageSendEventsProvider(null, bindings.LDKChannelMessageHandler_get_MessageSendEventsProvider(this.ptr));
269 res.ptrs_to.add(this);
274 * Handle an incoming `open_channel` message from the given peer.
276 public void handle_open_channel(byte[] their_node_id, org.ldk.structs.OpenChannel msg) {
277 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
278 Reference.reachabilityFence(this);
279 Reference.reachabilityFence(their_node_id);
280 Reference.reachabilityFence(msg);
281 if (this != null) { this.ptrs_to.add(msg); };
285 * Handle an incoming `accept_channel` message from the given peer.
287 public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.AcceptChannel msg) {
288 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
289 Reference.reachabilityFence(this);
290 Reference.reachabilityFence(their_node_id);
291 Reference.reachabilityFence(msg);
292 if (this != null) { this.ptrs_to.add(msg); };
296 * Handle an incoming `funding_created` message from the given peer.
298 public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
299 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
300 Reference.reachabilityFence(this);
301 Reference.reachabilityFence(their_node_id);
302 Reference.reachabilityFence(msg);
303 if (this != null) { this.ptrs_to.add(msg); };
307 * Handle an incoming `funding_signed` message from the given peer.
309 public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
310 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
311 Reference.reachabilityFence(this);
312 Reference.reachabilityFence(their_node_id);
313 Reference.reachabilityFence(msg);
314 if (this != null) { this.ptrs_to.add(msg); };
318 * Handle an incoming `channel_ready` message from the given peer.
320 public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
321 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
322 Reference.reachabilityFence(this);
323 Reference.reachabilityFence(their_node_id);
324 Reference.reachabilityFence(msg);
325 if (this != null) { this.ptrs_to.add(msg); };
329 * Handle an incoming `shutdown` message from the given peer.
331 public void handle_shutdown(byte[] their_node_id, org.ldk.structs.Shutdown msg) {
332 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
333 Reference.reachabilityFence(this);
334 Reference.reachabilityFence(their_node_id);
335 Reference.reachabilityFence(msg);
336 if (this != null) { this.ptrs_to.add(msg); };
340 * Handle an incoming `closing_signed` message from the given peer.
342 public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
343 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
344 Reference.reachabilityFence(this);
345 Reference.reachabilityFence(their_node_id);
346 Reference.reachabilityFence(msg);
347 if (this != null) { this.ptrs_to.add(msg); };
351 * Handle an incoming `update_add_htlc` message from the given peer.
353 public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
354 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
355 Reference.reachabilityFence(this);
356 Reference.reachabilityFence(their_node_id);
357 Reference.reachabilityFence(msg);
358 if (this != null) { this.ptrs_to.add(msg); };
362 * Handle an incoming `update_fulfill_htlc` message from the given peer.
364 public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
365 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
366 Reference.reachabilityFence(this);
367 Reference.reachabilityFence(their_node_id);
368 Reference.reachabilityFence(msg);
369 if (this != null) { this.ptrs_to.add(msg); };
373 * Handle an incoming `update_fail_htlc` message from the given peer.
375 public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
376 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
377 Reference.reachabilityFence(this);
378 Reference.reachabilityFence(their_node_id);
379 Reference.reachabilityFence(msg);
380 if (this != null) { this.ptrs_to.add(msg); };
384 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
386 public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
387 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
388 Reference.reachabilityFence(this);
389 Reference.reachabilityFence(their_node_id);
390 Reference.reachabilityFence(msg);
391 if (this != null) { this.ptrs_to.add(msg); };
395 * Handle an incoming `commitment_signed` message from the given peer.
397 public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
398 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
399 Reference.reachabilityFence(this);
400 Reference.reachabilityFence(their_node_id);
401 Reference.reachabilityFence(msg);
402 if (this != null) { this.ptrs_to.add(msg); };
406 * Handle an incoming `revoke_and_ack` message from the given peer.
408 public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
409 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
410 Reference.reachabilityFence(this);
411 Reference.reachabilityFence(their_node_id);
412 Reference.reachabilityFence(msg);
413 if (this != null) { this.ptrs_to.add(msg); };
417 * Handle an incoming `update_fee` message from the given peer.
419 public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
420 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
421 Reference.reachabilityFence(this);
422 Reference.reachabilityFence(their_node_id);
423 Reference.reachabilityFence(msg);
424 if (this != null) { this.ptrs_to.add(msg); };
428 * Handle an incoming `announcement_signatures` message from the given peer.
430 public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
431 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
432 Reference.reachabilityFence(this);
433 Reference.reachabilityFence(their_node_id);
434 Reference.reachabilityFence(msg);
435 if (this != null) { this.ptrs_to.add(msg); };
439 * Indicates a connection to the peer failed/an existing connection was lost.
441 public void peer_disconnected(byte[] their_node_id) {
442 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
443 Reference.reachabilityFence(this);
444 Reference.reachabilityFence(their_node_id);
448 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
450 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
451 * with us. Implementors should be somewhat conservative about doing so, however, as other
452 * message handlers may still wish to communicate with this peer.
454 public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg, boolean inbound) {
455 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr, inbound);
456 Reference.reachabilityFence(this);
457 Reference.reachabilityFence(their_node_id);
458 Reference.reachabilityFence(msg);
459 Reference.reachabilityFence(inbound);
460 if (ret >= 0 && ret <= 4096) { return null; }
461 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
462 if (this != null) { this.ptrs_to.add(msg); };
467 * Handle an incoming `channel_reestablish` message from the given peer.
469 public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
470 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
471 Reference.reachabilityFence(this);
472 Reference.reachabilityFence(their_node_id);
473 Reference.reachabilityFence(msg);
474 if (this != null) { this.ptrs_to.add(msg); };
478 * Handle an incoming `channel_update` message from the given peer.
480 public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
481 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
482 Reference.reachabilityFence(this);
483 Reference.reachabilityFence(their_node_id);
484 Reference.reachabilityFence(msg);
485 if (this != null) { this.ptrs_to.add(msg); };
489 * Handle an incoming `error` message from the given peer.
491 public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
492 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
493 Reference.reachabilityFence(this);
494 Reference.reachabilityFence(their_node_id);
495 Reference.reachabilityFence(msg);
496 if (this != null) { this.ptrs_to.add(msg); };
500 * Gets the node feature flags which this handler itself supports. All available handlers are
501 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
502 * which are broadcasted in our [`NodeAnnouncement`] message.
504 public NodeFeatures provided_node_features() {
505 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
506 Reference.reachabilityFence(this);
507 if (ret >= 0 && ret <= 4096) { return null; }
508 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
509 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
514 * Gets the init feature flags which should be sent to the given peer. All available handlers
515 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
516 * which are sent in our [`Init`] message.
518 * Note that this method is called before [`Self::peer_connected`].
520 public InitFeatures provided_init_features(byte[] their_node_id) {
521 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
522 Reference.reachabilityFence(this);
523 Reference.reachabilityFence(their_node_id);
524 if (ret >= 0 && ret <= 4096) { return null; }
525 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
526 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };