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 * Note that in some rare cases this may be called without a corresponding
99 * [`Self::peer_connected`].
101 void peer_disconnected(byte[] their_node_id, boolean no_connection_possible);
103 * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
105 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
106 * with us. Implementors should be somewhat conservative about doing so, however, as other
107 * message handlers may still wish to communicate with this peer.
109 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg);
111 * Handle an incoming channel_reestablish message from the given peer.
113 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
115 * Handle an incoming channel update from the given peer.
117 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
119 * Handle an incoming error message from the given peer.
121 void handle_error(byte[] their_node_id, ErrorMessage msg);
123 * Gets the node feature flags which this handler itself supports. All available handlers are
124 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
125 * which are broadcasted in our [`NodeAnnouncement`] message.
127 NodeFeatures provided_node_features();
129 * Gets the init feature flags which should be sent to the given peer. All available handlers
130 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
131 * which are sent in our [`Init`] message.
133 * Note that this method is called before [`Self::peer_connected`].
135 InitFeatures provided_init_features(byte[] their_node_id);
137 private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; }
138 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) {
139 final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
140 impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
141 @Override public void handle_open_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.OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.OpenChannel(null, msg); }
145 arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
146 Reference.reachabilityFence(arg);
148 @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
149 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); }
150 if (their_features_hu_conv != null) { their_features_hu_conv.ptrs_to.add(this); };
151 org.ldk.structs.AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AcceptChannel(null, msg); }
152 arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
153 Reference.reachabilityFence(arg);
155 @Override public void handle_funding_created(byte[] their_node_id, long msg) {
156 org.ldk.structs.FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingCreated(null, msg); }
157 arg.handle_funding_created(their_node_id, msg_hu_conv);
158 Reference.reachabilityFence(arg);
160 @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
161 org.ldk.structs.FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.FundingSigned(null, msg); }
162 arg.handle_funding_signed(their_node_id, msg_hu_conv);
163 Reference.reachabilityFence(arg);
165 @Override public void handle_channel_ready(byte[] their_node_id, long msg) {
166 org.ldk.structs.ChannelReady msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReady(null, msg); }
167 arg.handle_channel_ready(their_node_id, msg_hu_conv);
168 Reference.reachabilityFence(arg);
170 @Override public void handle_shutdown(byte[] their_node_id, long their_features, long msg) {
171 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); }
172 org.ldk.structs.Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Shutdown(null, msg); }
173 arg.handle_shutdown(their_node_id, their_features_hu_conv, msg_hu_conv);
174 Reference.reachabilityFence(arg);
176 @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
177 org.ldk.structs.ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ClosingSigned(null, msg); }
178 arg.handle_closing_signed(their_node_id, msg_hu_conv);
179 Reference.reachabilityFence(arg);
181 @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
182 org.ldk.structs.UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, msg); }
183 arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
184 Reference.reachabilityFence(arg);
186 @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
187 org.ldk.structs.UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, msg); }
188 arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
189 Reference.reachabilityFence(arg);
191 @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
192 org.ldk.structs.UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, msg); }
193 arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
194 Reference.reachabilityFence(arg);
196 @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
197 org.ldk.structs.UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, msg); }
198 arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
199 Reference.reachabilityFence(arg);
201 @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
202 org.ldk.structs.CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, msg); }
203 arg.handle_commitment_signed(their_node_id, msg_hu_conv);
204 Reference.reachabilityFence(arg);
206 @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
207 org.ldk.structs.RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, msg); }
208 arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
209 Reference.reachabilityFence(arg);
211 @Override public void handle_update_fee(byte[] their_node_id, long msg) {
212 org.ldk.structs.UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UpdateFee(null, msg); }
213 arg.handle_update_fee(their_node_id, msg_hu_conv);
214 Reference.reachabilityFence(arg);
216 @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
217 org.ldk.structs.AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, msg); }
218 arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
219 Reference.reachabilityFence(arg);
221 @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
222 arg.peer_disconnected(their_node_id, no_connection_possible);
223 Reference.reachabilityFence(arg);
225 @Override public long peer_connected(byte[] their_node_id, long msg) {
226 org.ldk.structs.Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.Init(null, msg); }
227 Result_NoneNoneZ ret = arg.peer_connected(their_node_id, msg_hu_conv);
228 Reference.reachabilityFence(arg);
229 long result = ret == null ? 0 : ret.clone_ptr();
232 @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
233 org.ldk.structs.ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, msg); }
234 arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
235 Reference.reachabilityFence(arg);
237 @Override public void handle_channel_update(byte[] their_node_id, long msg) {
238 org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); }
239 arg.handle_channel_update(their_node_id, msg_hu_conv);
240 Reference.reachabilityFence(arg);
242 @Override public void handle_error(byte[] their_node_id, long msg) {
243 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
244 arg.handle_error(their_node_id, msg_hu_conv);
245 Reference.reachabilityFence(arg);
247 @Override public long provided_node_features() {
248 NodeFeatures ret = arg.provided_node_features();
249 Reference.reachabilityFence(arg);
250 long result = ret == null ? 0 : ret.clone_ptr();
253 @Override public long provided_init_features(byte[] their_node_id) {
254 InitFeatures ret = arg.provided_init_features(their_node_id);
255 Reference.reachabilityFence(arg);
256 long result = ret == null ? 0 : ret.clone_ptr();
259 }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
260 return impl_holder.held;
264 * Gets the underlying MessageSendEventsProvider.
266 public MessageSendEventsProvider get_message_send_events_provider() {
267 MessageSendEventsProvider res = new MessageSendEventsProvider(null, bindings.LDKChannelMessageHandler_get_MessageSendEventsProvider(this.ptr));
268 this.ptrs_to.add(res);
273 * Handle an incoming open_channel message from the given peer.
275 public void handle_open_channel(byte[] their_node_id, org.ldk.structs.InitFeatures their_features, org.ldk.structs.OpenChannel msg) {
276 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);
277 Reference.reachabilityFence(this);
278 Reference.reachabilityFence(their_node_id);
279 Reference.reachabilityFence(their_features);
280 Reference.reachabilityFence(msg);
281 if (this != null) { this.ptrs_to.add(their_features); };
282 if (this != null) { this.ptrs_to.add(msg); };
286 * Handle an incoming accept_channel message from the given peer.
288 public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.InitFeatures their_features, org.ldk.structs.AcceptChannel msg) {
289 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);
290 Reference.reachabilityFence(this);
291 Reference.reachabilityFence(their_node_id);
292 Reference.reachabilityFence(their_features);
293 Reference.reachabilityFence(msg);
294 if (this != null) { this.ptrs_to.add(their_features); };
295 if (this != null) { this.ptrs_to.add(msg); };
299 * Handle an incoming funding_created message from the given peer.
301 public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
302 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
303 Reference.reachabilityFence(this);
304 Reference.reachabilityFence(their_node_id);
305 Reference.reachabilityFence(msg);
306 if (this != null) { this.ptrs_to.add(msg); };
310 * Handle an incoming funding_signed message from the given peer.
312 public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
313 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
314 Reference.reachabilityFence(this);
315 Reference.reachabilityFence(their_node_id);
316 Reference.reachabilityFence(msg);
317 if (this != null) { this.ptrs_to.add(msg); };
321 * Handle an incoming channel_ready message from the given peer.
323 public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
324 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
325 Reference.reachabilityFence(this);
326 Reference.reachabilityFence(their_node_id);
327 Reference.reachabilityFence(msg);
328 if (this != null) { this.ptrs_to.add(msg); };
332 * Handle an incoming shutdown message from the given peer.
334 public void handle_shutdown(byte[] their_node_id, org.ldk.structs.InitFeatures their_features, org.ldk.structs.Shutdown msg) {
335 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);
336 Reference.reachabilityFence(this);
337 Reference.reachabilityFence(their_node_id);
338 Reference.reachabilityFence(their_features);
339 Reference.reachabilityFence(msg);
340 if (this != null) { this.ptrs_to.add(their_features); };
341 if (this != null) { this.ptrs_to.add(msg); };
345 * Handle an incoming closing_signed message from the given peer.
347 public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
348 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
349 Reference.reachabilityFence(this);
350 Reference.reachabilityFence(their_node_id);
351 Reference.reachabilityFence(msg);
352 if (this != null) { this.ptrs_to.add(msg); };
356 * Handle an incoming update_add_htlc message from the given peer.
358 public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
359 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
360 Reference.reachabilityFence(this);
361 Reference.reachabilityFence(their_node_id);
362 Reference.reachabilityFence(msg);
363 if (this != null) { this.ptrs_to.add(msg); };
367 * Handle an incoming update_fulfill_htlc message from the given peer.
369 public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
370 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
371 Reference.reachabilityFence(this);
372 Reference.reachabilityFence(their_node_id);
373 Reference.reachabilityFence(msg);
374 if (this != null) { this.ptrs_to.add(msg); };
378 * Handle an incoming update_fail_htlc message from the given peer.
380 public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
381 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
382 Reference.reachabilityFence(this);
383 Reference.reachabilityFence(their_node_id);
384 Reference.reachabilityFence(msg);
385 if (this != null) { this.ptrs_to.add(msg); };
389 * Handle an incoming update_fail_malformed_htlc message from the given peer.
391 public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
392 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
393 Reference.reachabilityFence(this);
394 Reference.reachabilityFence(their_node_id);
395 Reference.reachabilityFence(msg);
396 if (this != null) { this.ptrs_to.add(msg); };
400 * Handle an incoming commitment_signed message from the given peer.
402 public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
403 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
404 Reference.reachabilityFence(this);
405 Reference.reachabilityFence(their_node_id);
406 Reference.reachabilityFence(msg);
407 if (this != null) { this.ptrs_to.add(msg); };
411 * Handle an incoming revoke_and_ack message from the given peer.
413 public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
414 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
415 Reference.reachabilityFence(this);
416 Reference.reachabilityFence(their_node_id);
417 Reference.reachabilityFence(msg);
418 if (this != null) { this.ptrs_to.add(msg); };
422 * Handle an incoming update_fee message from the given peer.
424 public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
425 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
426 Reference.reachabilityFence(this);
427 Reference.reachabilityFence(their_node_id);
428 Reference.reachabilityFence(msg);
429 if (this != null) { this.ptrs_to.add(msg); };
433 * Handle an incoming announcement_signatures message from the given peer.
435 public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
436 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
437 Reference.reachabilityFence(this);
438 Reference.reachabilityFence(their_node_id);
439 Reference.reachabilityFence(msg);
440 if (this != null) { this.ptrs_to.add(msg); };
444 * Indicates a connection to the peer failed/an existing connection was lost. If no connection
445 * is believed to be possible in the future (eg they're sending us messages we don't
446 * understand or indicate they require unknown feature bits), no_connection_possible is set
447 * and any outstanding channels should be failed.
449 * Note that in some rare cases this may be called without a corresponding
450 * [`Self::peer_connected`].
452 public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
453 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), no_connection_possible);
454 Reference.reachabilityFence(this);
455 Reference.reachabilityFence(their_node_id);
456 Reference.reachabilityFence(no_connection_possible);
460 * Handle a peer reconnecting, possibly generating channel_reestablish message(s).
462 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
463 * with us. Implementors should be somewhat conservative about doing so, however, as other
464 * message handlers may still wish to communicate with this peer.
466 public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg) {
467 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.check_arr_len(their_node_id, 33), msg == null ? 0 : msg.ptr);
468 Reference.reachabilityFence(this);
469 Reference.reachabilityFence(their_node_id);
470 Reference.reachabilityFence(msg);
471 if (ret >= 0 && ret <= 4096) { return null; }
472 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
473 if (this != null) { this.ptrs_to.add(msg); };
478 * Handle an incoming channel_reestablish message from the given peer.
480 public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
481 bindings.ChannelMessageHandler_handle_channel_reestablish(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 update from the given peer.
491 public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
492 bindings.ChannelMessageHandler_handle_channel_update(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 error message from the given peer.
502 public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
503 bindings.ChannelMessageHandler_handle_error(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 * Gets the node feature flags which this handler itself supports. All available handlers are
512 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
513 * which are broadcasted in our [`NodeAnnouncement`] message.
515 public NodeFeatures provided_node_features() {
516 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
517 Reference.reachabilityFence(this);
518 if (ret >= 0 && ret <= 4096) { return null; }
519 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
520 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
525 * Gets the init feature flags which should be sent to the given peer. All available handlers
526 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
527 * which are sent in our [`Init`] message.
529 * Note that this method is called before [`Self::peer_connected`].
531 public InitFeatures provided_init_features(byte[] their_node_id) {
532 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.check_arr_len(their_node_id, 33));
533 Reference.reachabilityFence(this);
534 Reference.reachabilityFence(their_node_id);
535 if (ret >= 0 && ret <= 4096) { return null; }
536 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
537 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };