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 public static interface ChannelMessageHandlerInterface {
33 * Handle an incoming open_channel message from the given peer.
35 void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg);
37 * Handle an incoming accept_channel message from the given peer.
39 void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg);
41 * Handle an incoming funding_created message from the given peer.
43 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
45 * Handle an incoming funding_signed message from the given peer.
47 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
49 * Handle an incoming channel_ready message from the given peer.
51 void handle_channel_ready(byte[] their_node_id, ChannelReady msg);
53 * Handle an incoming shutdown message from the given peer.
55 void handle_shutdown(byte[] their_node_id, InitFeatures their_features, Shutdown msg);
57 * Handle an incoming closing_signed message from the given peer.
59 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
61 * Handle an incoming update_add_htlc message from the given peer.
63 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
65 * Handle an incoming update_fulfill_htlc message from the given peer.
67 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
69 * Handle an incoming update_fail_htlc message from the given peer.
71 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
73 * Handle an incoming update_fail_malformed_htlc message from the given peer.
75 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
77 * Handle an incoming commitment_signed message from the given peer.
79 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
81 * Handle an incoming revoke_and_ack message from the given peer.
83 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
85 * Handle an incoming update_fee message from the given peer.
87 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
89 * Handle an incoming announcement_signatures message from the given peer.
91 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
93 * Indicates a connection to the peer failed/an existing connection was lost. If no connection
94 * is believed to be possible in the future (eg they're sending us messages we don't
95 * understand or indicate they require unknown feature bits), no_connection_possible is set
96 * and any outstanding channels should be failed.
98 void peer_disconnected(byte[] their_node_id, boolean no_connection_possible);
100 * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
102 void peer_connected(byte[] their_node_id, Init msg);
104 * Handle an incoming channel_reestablish message from the given peer.
106 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
108 * Handle an incoming channel update from the given peer.
110 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
112 * Handle an incoming error message from the given peer.
114 void handle_error(byte[] their_node_id, ErrorMessage msg);
116 * Gets the node feature flags which this handler itself supports. All available handlers are
117 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
118 * which are broadcasted in our [`NodeAnnouncement`] message.
120 NodeFeatures provided_node_features();
122 * Gets the init feature flags which should be sent to the given peer. All available handlers
123 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
124 * which are sent in our [`Init`] message.
126 * Note that this method is called before [`Self::peer_connected`].
128 InitFeatures provided_init_features(byte[] their_node_id);
130 private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
131 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
132 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
133 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
134 @Override public void handle_open_channel(byte[] their_node_id, long their_features, long msg) {
135 org.ldk.structs.InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new org.ldk.structs.InitFeatures(null, their_features); }
136 if (their_features_hu_conv != null) { their_features_hu_conv.ptrs_to.add(this); };
137 org.ldk.structs.OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannel(null, msg); }
138 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
139 Reference.reachabilityFence(arg);
141 @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
142 org.ldk.structs.InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new org.ldk.structs.InitFeatures(null, their_features); }
143 if (their_features_hu_conv != null) { their_features_hu_conv.ptrs_to.add(this); };
144 org.ldk.structs.AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannel(null, msg); }
145 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
146 Reference.reachabilityFence(arg);
148 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
149 org.ldk.structs.FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingCreated(null, msg); }
150 arg.handle_funding_created(their_node_id, msg_hu_conv);
151 Reference.reachabilityFence(arg);
153 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
154 org.ldk.structs.FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingSigned(null, msg); }
155 arg.handle_funding_signed(their_node_id, msg_hu_conv);
156 Reference.reachabilityFence(arg);
158 @Override public void handle_channel_ready(byte[] their_node_id, long msg) {
159 org.ldk.structs.ChannelReady msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReady(null, msg); }
160 arg.handle_channel_ready(their_node_id, msg_hu_conv);
161 Reference.reachabilityFence(arg);
163 @Override public void handle_shutdown(byte[] their_node_id, long their_features, long msg) {
164 org.ldk.structs.InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new org.ldk.structs.InitFeatures(null, their_features); }
165 org.ldk.structs.Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Shutdown(null, msg); }
166 arg.handle_shutdown(their_node_id, their_features_hu_conv, msg_hu_conv);
167 Reference.reachabilityFence(arg);
169 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
170 org.ldk.structs.ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ClosingSigned(null, msg); }
171 arg.handle_closing_signed(their_node_id, msg_hu_conv);
172 Reference.reachabilityFence(arg);
174 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
175 org.ldk.structs.UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, msg); }
176 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
177 Reference.reachabilityFence(arg);
179 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
180 org.ldk.structs.UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, msg); }
181 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
182 Reference.reachabilityFence(arg);
184 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
185 org.ldk.structs.UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, msg); }
186 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
187 Reference.reachabilityFence(arg);
189 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
190 org.ldk.structs.UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, msg); }
191 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
192 Reference.reachabilityFence(arg);
194 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
195 org.ldk.structs.CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, msg); }
196 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
197 Reference.reachabilityFence(arg);
199 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
200 org.ldk.structs.RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, msg); }
201 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
202 Reference.reachabilityFence(arg);
204 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
205 org.ldk.structs.UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFee(null, msg); }
206 arg.handle_update_fee(their_node_id, msg_hu_conv);
207 Reference.reachabilityFence(arg);
209 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
210 org.ldk.structs.AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, msg); }
211 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
212 Reference.reachabilityFence(arg);
214 @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
215 arg.peer_disconnected(their_node_id, no_connection_possible);
216 Reference.reachabilityFence(arg);
218 @Override public void peer_connected(byte[] their_node_id, long msg) {
219 org.ldk.structs.Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Init(null, msg); }
220 arg.peer_connected(their_node_id, msg_hu_conv);
221 Reference.reachabilityFence(arg);
223 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
224 org.ldk.structs.ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, msg); }
225 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
226 Reference.reachabilityFence(arg);
228 @Override public void handle_channel_update(byte[] their_node_id, long msg) {
229 org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); }
230 arg.handle_channel_update(their_node_id, msg_hu_conv);
231 Reference.reachabilityFence(arg);
233 @Override public void handle_error(byte[] their_node_id, long msg) {
234 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
235 arg.handle_error(their_node_id, msg_hu_conv);
236 Reference.reachabilityFence(arg);
238 @Override public long provided_node_features() {
239 NodeFeatures ret = arg.provided_node_features();
240 Reference.reachabilityFence(arg);
241 long result = ret == null ? 0 : ret.clone_ptr();
244 @Override public long provided_init_features(byte[] their_node_id) {
245 InitFeatures ret = arg.provided_init_features(their_node_id);
246 Reference.reachabilityFence(arg);
247 long result = ret == null ? 0 : ret.clone_ptr();
250 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
251 return impl_holder.held;
255 * Gets the underlying MessageSendEventsProvider.
257 public MessageSendEventsProvider get_message_send_events_provider() {
258 MessageSendEventsProvider res = new MessageSendEventsProvider(null, bindings.LDKChannelMessageHandler_get_MessageSendEventsProvider(this.ptr));
259 this.ptrs_to.add(res);
264 * Handle an incoming open_channel message from the given peer.
266 public void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg) {
267 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), their_features == null ? 0 : their_features.ptr, msg == null ? 0 : msg.ptr);
268 Reference.reachabilityFence(this);
269 Reference.reachabilityFence(their_node_id);
270 Reference.reachabilityFence(their_features);
271 Reference.reachabilityFence(msg);
272 if (this != null) { this.ptrs_to.add(their_features); };
273 if (this != null) { this.ptrs_to.add(msg); };
277 * Handle an incoming accept_channel message from the given peer.
279 public void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg) {
280 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), their_features == null ? 0 : their_features.ptr, msg == null ? 0 : msg.ptr);
281 Reference.reachabilityFence(this);
282 Reference.reachabilityFence(their_node_id);
283 Reference.reachabilityFence(their_features);
284 Reference.reachabilityFence(msg);
285 if (this != null) { this.ptrs_to.add(their_features); };
286 if (this != null) { this.ptrs_to.add(msg); };
290 * Handle an incoming funding_created message from the given peer.
292 public void handle_funding_created(byte[] their_node_id, FundingCreated msg) {
293 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
294 Reference.reachabilityFence(this);
295 Reference.reachabilityFence(their_node_id);
296 Reference.reachabilityFence(msg);
297 if (this != null) { this.ptrs_to.add(msg); };
301 * Handle an incoming funding_signed message from the given peer.
303 public void handle_funding_signed(byte[] their_node_id, FundingSigned msg) {
304 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
305 Reference.reachabilityFence(this);
306 Reference.reachabilityFence(their_node_id);
307 Reference.reachabilityFence(msg);
308 if (this != null) { this.ptrs_to.add(msg); };
312 * Handle an incoming channel_ready message from the given peer.
314 public void handle_channel_ready(byte[] their_node_id, ChannelReady msg) {
315 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
316 Reference.reachabilityFence(this);
317 Reference.reachabilityFence(their_node_id);
318 Reference.reachabilityFence(msg);
319 if (this != null) { this.ptrs_to.add(msg); };
323 * Handle an incoming shutdown message from the given peer.
325 public void handle_shutdown(byte[] their_node_id, InitFeatures their_features, Shutdown msg) {
326 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), their_features == null ? 0 : their_features.ptr, msg == null ? 0 : msg.ptr);
327 Reference.reachabilityFence(this);
328 Reference.reachabilityFence(their_node_id);
329 Reference.reachabilityFence(their_features);
330 Reference.reachabilityFence(msg);
331 if (this != null) { this.ptrs_to.add(their_features); };
332 if (this != null) { this.ptrs_to.add(msg); };
336 * Handle an incoming closing_signed message from the given peer.
338 public void handle_closing_signed(byte[] their_node_id, ClosingSigned msg) {
339 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
340 Reference.reachabilityFence(this);
341 Reference.reachabilityFence(their_node_id);
342 Reference.reachabilityFence(msg);
343 if (this != null) { this.ptrs_to.add(msg); };
347 * Handle an incoming update_add_htlc message from the given peer.
349 public void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg) {
350 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
351 Reference.reachabilityFence(this);
352 Reference.reachabilityFence(their_node_id);
353 Reference.reachabilityFence(msg);
354 if (this != null) { this.ptrs_to.add(msg); };
358 * Handle an incoming update_fulfill_htlc message from the given peer.
360 public void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg) {
361 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
362 Reference.reachabilityFence(this);
363 Reference.reachabilityFence(their_node_id);
364 Reference.reachabilityFence(msg);
365 if (this != null) { this.ptrs_to.add(msg); };
369 * Handle an incoming update_fail_htlc message from the given peer.
371 public void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg) {
372 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
373 Reference.reachabilityFence(this);
374 Reference.reachabilityFence(their_node_id);
375 Reference.reachabilityFence(msg);
376 if (this != null) { this.ptrs_to.add(msg); };
380 * Handle an incoming update_fail_malformed_htlc message from the given peer.
382 public void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg) {
383 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
384 Reference.reachabilityFence(this);
385 Reference.reachabilityFence(their_node_id);
386 Reference.reachabilityFence(msg);
387 if (this != null) { this.ptrs_to.add(msg); };
391 * Handle an incoming commitment_signed message from the given peer.
393 public void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg) {
394 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
395 Reference.reachabilityFence(this);
396 Reference.reachabilityFence(their_node_id);
397 Reference.reachabilityFence(msg);
398 if (this != null) { this.ptrs_to.add(msg); };
402 * Handle an incoming revoke_and_ack message from the given peer.
404 public void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg) {
405 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
406 Reference.reachabilityFence(this);
407 Reference.reachabilityFence(their_node_id);
408 Reference.reachabilityFence(msg);
409 if (this != null) { this.ptrs_to.add(msg); };
413 * Handle an incoming update_fee message from the given peer.
415 public void handle_update_fee(byte[] their_node_id, UpdateFee msg) {
416 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
417 Reference.reachabilityFence(this);
418 Reference.reachabilityFence(their_node_id);
419 Reference.reachabilityFence(msg);
420 if (this != null) { this.ptrs_to.add(msg); };
424 * Handle an incoming announcement_signatures message from the given peer.
426 public void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg) {
427 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
428 Reference.reachabilityFence(this);
429 Reference.reachabilityFence(their_node_id);
430 Reference.reachabilityFence(msg);
431 if (this != null) { this.ptrs_to.add(msg); };
435 * Indicates a connection to the peer failed/an existing connection was lost. If no connection
436 * is believed to be possible in the future (eg they're sending us messages we don't
437 * understand or indicate they require unknown feature bits), no_connection_possible is set
438 * and any outstanding channels should be failed.
440 public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
441 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), no_connection_possible);
442 Reference.reachabilityFence(this);
443 Reference.reachabilityFence(their_node_id);
444 Reference.reachabilityFence(no_connection_possible);
448 * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
450 public void peer_connected(byte[] their_node_id, Init msg) {
451 bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
452 Reference.reachabilityFence(this);
453 Reference.reachabilityFence(their_node_id);
454 Reference.reachabilityFence(msg);
455 if (this != null) { this.ptrs_to.add(msg); };
459 * Handle an incoming channel_reestablish message from the given peer.
461 public void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg) {
462 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
463 Reference.reachabilityFence(this);
464 Reference.reachabilityFence(their_node_id);
465 Reference.reachabilityFence(msg);
466 if (this != null) { this.ptrs_to.add(msg); };
470 * Handle an incoming channel update from the given peer.
472 public void handle_channel_update(byte[] their_node_id, ChannelUpdate msg) {
473 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
474 Reference.reachabilityFence(this);
475 Reference.reachabilityFence(their_node_id);
476 Reference.reachabilityFence(msg);
477 if (this != null) { this.ptrs_to.add(msg); };
481 * Handle an incoming error message from the given peer.
483 public void handle_error(byte[] their_node_id, ErrorMessage msg) {
484 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
485 Reference.reachabilityFence(this);
486 Reference.reachabilityFence(their_node_id);
487 Reference.reachabilityFence(msg);
488 if (this != null) { this.ptrs_to.add(msg); };
492 * Gets the node feature flags which this handler itself supports. All available handlers are
493 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
494 * which are broadcasted in our [`NodeAnnouncement`] message.
496 public NodeFeatures provided_node_features() {
497 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
498 Reference.reachabilityFence(this);
499 if (ret >= 0 && ret <= 4096) { return null; }
500 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
501 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
506 * Gets the init feature flags which should be sent to the given peer. All available handlers
507 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
508 * which are sent in our [`Init`] message.
510 * Note that this method is called before [`Self::peer_connected`].
512 public InitFeatures provided_init_features(byte[] their_node_id) {
513 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
514 Reference.reachabilityFence(this);
515 Reference.reachabilityFence(their_node_id);
516 if (ret >= 0 && ret <= 4096) { return null; }
517 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
518 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };