7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of ChannelMessageHandler */
12 public interface ChannelMessageHandlerInterface {
13 /**Handle an incoming `open_channel` message from the given peer.
15 void handle_open_channel(byte[] their_node_id, OpenChannel msg);
16 /**Handle an incoming `open_channel2` message from the given peer.
18 void handle_open_channel_v2(byte[] their_node_id, OpenChannelV2 msg);
19 /**Handle an incoming `accept_channel` message from the given peer.
21 void handle_accept_channel(byte[] their_node_id, AcceptChannel msg);
22 /**Handle an incoming `accept_channel2` message from the given peer.
24 void handle_accept_channel_v2(byte[] their_node_id, AcceptChannelV2 msg);
25 /**Handle an incoming `funding_created` message from the given peer.
27 void handle_funding_created(byte[] their_node_id, FundingCreated msg);
28 /**Handle an incoming `funding_signed` message from the given peer.
30 void handle_funding_signed(byte[] their_node_id, FundingSigned msg);
31 /**Handle an incoming `channel_ready` message from the given peer.
33 void handle_channel_ready(byte[] their_node_id, ChannelReady msg);
34 /**Handle an incoming `shutdown` message from the given peer.
36 void handle_shutdown(byte[] their_node_id, Shutdown msg);
37 /**Handle an incoming `closing_signed` message from the given peer.
39 void handle_closing_signed(byte[] their_node_id, ClosingSigned msg);
40 /**Handle an incoming `stfu` message from the given peer.
42 void handle_stfu(byte[] their_node_id, Stfu msg);
43 /**Handle an incoming `tx_add_input message` from the given peer.
45 void handle_tx_add_input(byte[] their_node_id, TxAddInput msg);
46 /**Handle an incoming `tx_add_output` message from the given peer.
48 void handle_tx_add_output(byte[] their_node_id, TxAddOutput msg);
49 /**Handle an incoming `tx_remove_input` message from the given peer.
51 void handle_tx_remove_input(byte[] their_node_id, TxRemoveInput msg);
52 /**Handle an incoming `tx_remove_output` message from the given peer.
54 void handle_tx_remove_output(byte[] their_node_id, TxRemoveOutput msg);
55 /**Handle an incoming `tx_complete message` from the given peer.
57 void handle_tx_complete(byte[] their_node_id, TxComplete msg);
58 /**Handle an incoming `tx_signatures` message from the given peer.
60 void handle_tx_signatures(byte[] their_node_id, TxSignatures msg);
61 /**Handle an incoming `tx_init_rbf` message from the given peer.
63 void handle_tx_init_rbf(byte[] their_node_id, TxInitRbf msg);
64 /**Handle an incoming `tx_ack_rbf` message from the given peer.
66 void handle_tx_ack_rbf(byte[] their_node_id, TxAckRbf msg);
67 /**Handle an incoming `tx_abort message` from the given peer.
69 void handle_tx_abort(byte[] their_node_id, TxAbort msg);
70 /**Handle an incoming `update_add_htlc` message from the given peer.
72 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
73 /**Handle an incoming `update_fulfill_htlc` message from the given peer.
75 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
76 /**Handle an incoming `update_fail_htlc` message from the given peer.
78 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
79 /**Handle an incoming `update_fail_malformed_htlc` message from the given peer.
81 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
82 /**Handle an incoming `commitment_signed` message from the given peer.
84 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
85 /**Handle an incoming `revoke_and_ack` message from the given peer.
87 void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg);
88 /**Handle an incoming `update_fee` message from the given peer.
90 void handle_update_fee(byte[] their_node_id, UpdateFee msg);
91 /**Handle an incoming `announcement_signatures` message from the given peer.
93 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
94 /**Indicates a connection to the peer failed/an existing connection was lost.
96 void peer_disconnected(byte[] their_node_id);
97 /**Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
99 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
100 * with us. Implementors should be somewhat conservative about doing so, however, as other
101 * message handlers may still wish to communicate with this peer.
103 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, bool inbound);
104 /**Handle an incoming `channel_reestablish` message from the given peer.
106 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
107 /**Handle an incoming `channel_update` message from the given peer.
109 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
110 /**Handle an incoming `error` message from the given peer.
112 void handle_error(byte[] their_node_id, ErrorMessage msg);
113 /**Gets the node feature flags which this handler itself supports. All available handlers are
114 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
115 * which are broadcasted in our [`NodeAnnouncement`] message.
117 NodeFeatures provided_node_features();
118 /**Gets the init feature flags which should be sent to the given peer. All available handlers
119 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
120 * which are sent in our [`Init`] message.
122 * Note that this method is called before [`Self::peer_connected`].
124 InitFeatures provided_init_features(byte[] their_node_id);
125 /**Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
127 * If it's `None`, then no particular network chain hash compatibility will be enforced when
128 * connecting to peers.
130 Option_CVec_ThirtyTwoBytesZZ get_chain_hashes();
134 * A trait to describe an object which can receive channel messages.
136 * Messages MAY be called in parallel when they originate from different `their_node_ids`, however
137 * they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
139 public class ChannelMessageHandler : CommonBase {
140 internal bindings.LDKChannelMessageHandler bindings_instance;
141 internal long instance_idx;
143 internal ChannelMessageHandler(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
144 ~ChannelMessageHandler() {
145 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); }
148 private class LDKChannelMessageHandlerHolder { internal ChannelMessageHandler held; }
149 private class LDKChannelMessageHandlerImpl : bindings.LDKChannelMessageHandler {
150 internal LDKChannelMessageHandlerImpl(ChannelMessageHandlerInterface arg, LDKChannelMessageHandlerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
151 private ChannelMessageHandlerInterface arg;
152 private LDKChannelMessageHandlerHolder impl_holder;
153 public void handle_open_channel(long _their_node_id, long _msg) {
154 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
155 org.ldk.structs.OpenChannel _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.OpenChannel(null, _msg); }
156 arg.handle_open_channel(_their_node_id_conv, _msg_hu_conv);
159 public void handle_open_channel_v2(long _their_node_id, long _msg) {
160 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
161 org.ldk.structs.OpenChannelV2 _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.OpenChannelV2(null, _msg); }
162 arg.handle_open_channel_v2(_their_node_id_conv, _msg_hu_conv);
165 public void handle_accept_channel(long _their_node_id, long _msg) {
166 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
167 org.ldk.structs.AcceptChannel _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AcceptChannel(null, _msg); }
168 arg.handle_accept_channel(_their_node_id_conv, _msg_hu_conv);
171 public void handle_accept_channel_v2(long _their_node_id, long _msg) {
172 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
173 org.ldk.structs.AcceptChannelV2 _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AcceptChannelV2(null, _msg); }
174 arg.handle_accept_channel_v2(_their_node_id_conv, _msg_hu_conv);
177 public void handle_funding_created(long _their_node_id, long _msg) {
178 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
179 org.ldk.structs.FundingCreated _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.FundingCreated(null, _msg); }
180 arg.handle_funding_created(_their_node_id_conv, _msg_hu_conv);
183 public void handle_funding_signed(long _their_node_id, long _msg) {
184 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
185 org.ldk.structs.FundingSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.FundingSigned(null, _msg); }
186 arg.handle_funding_signed(_their_node_id_conv, _msg_hu_conv);
189 public void handle_channel_ready(long _their_node_id, long _msg) {
190 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
191 org.ldk.structs.ChannelReady _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelReady(null, _msg); }
192 arg.handle_channel_ready(_their_node_id_conv, _msg_hu_conv);
195 public void handle_shutdown(long _their_node_id, long _msg) {
196 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
197 org.ldk.structs.Shutdown _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Shutdown(null, _msg); }
198 arg.handle_shutdown(_their_node_id_conv, _msg_hu_conv);
201 public void handle_closing_signed(long _their_node_id, long _msg) {
202 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
203 org.ldk.structs.ClosingSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ClosingSigned(null, _msg); }
204 arg.handle_closing_signed(_their_node_id_conv, _msg_hu_conv);
207 public void handle_stfu(long _their_node_id, long _msg) {
208 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
209 org.ldk.structs.Stfu _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Stfu(null, _msg); }
210 arg.handle_stfu(_their_node_id_conv, _msg_hu_conv);
213 public void handle_tx_add_input(long _their_node_id, long _msg) {
214 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
215 org.ldk.structs.TxAddInput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAddInput(null, _msg); }
216 arg.handle_tx_add_input(_their_node_id_conv, _msg_hu_conv);
219 public void handle_tx_add_output(long _their_node_id, long _msg) {
220 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
221 org.ldk.structs.TxAddOutput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAddOutput(null, _msg); }
222 arg.handle_tx_add_output(_their_node_id_conv, _msg_hu_conv);
225 public void handle_tx_remove_input(long _their_node_id, long _msg) {
226 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
227 org.ldk.structs.TxRemoveInput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxRemoveInput(null, _msg); }
228 arg.handle_tx_remove_input(_their_node_id_conv, _msg_hu_conv);
231 public void handle_tx_remove_output(long _their_node_id, long _msg) {
232 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
233 org.ldk.structs.TxRemoveOutput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxRemoveOutput(null, _msg); }
234 arg.handle_tx_remove_output(_their_node_id_conv, _msg_hu_conv);
237 public void handle_tx_complete(long _their_node_id, long _msg) {
238 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
239 org.ldk.structs.TxComplete _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxComplete(null, _msg); }
240 arg.handle_tx_complete(_their_node_id_conv, _msg_hu_conv);
243 public void handle_tx_signatures(long _their_node_id, long _msg) {
244 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
245 org.ldk.structs.TxSignatures _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxSignatures(null, _msg); }
246 arg.handle_tx_signatures(_their_node_id_conv, _msg_hu_conv);
249 public void handle_tx_init_rbf(long _their_node_id, long _msg) {
250 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
251 org.ldk.structs.TxInitRbf _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxInitRbf(null, _msg); }
252 arg.handle_tx_init_rbf(_their_node_id_conv, _msg_hu_conv);
255 public void handle_tx_ack_rbf(long _their_node_id, long _msg) {
256 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
257 org.ldk.structs.TxAckRbf _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAckRbf(null, _msg); }
258 arg.handle_tx_ack_rbf(_their_node_id_conv, _msg_hu_conv);
261 public void handle_tx_abort(long _their_node_id, long _msg) {
262 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
263 org.ldk.structs.TxAbort _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAbort(null, _msg); }
264 arg.handle_tx_abort(_their_node_id_conv, _msg_hu_conv);
267 public void handle_update_add_htlc(long _their_node_id, long _msg) {
268 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
269 org.ldk.structs.UpdateAddHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, _msg); }
270 arg.handle_update_add_htlc(_their_node_id_conv, _msg_hu_conv);
273 public void handle_update_fulfill_htlc(long _their_node_id, long _msg) {
274 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
275 org.ldk.structs.UpdateFulfillHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, _msg); }
276 arg.handle_update_fulfill_htlc(_their_node_id_conv, _msg_hu_conv);
279 public void handle_update_fail_htlc(long _their_node_id, long _msg) {
280 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
281 org.ldk.structs.UpdateFailHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, _msg); }
282 arg.handle_update_fail_htlc(_their_node_id_conv, _msg_hu_conv);
285 public void handle_update_fail_malformed_htlc(long _their_node_id, long _msg) {
286 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
287 org.ldk.structs.UpdateFailMalformedHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, _msg); }
288 arg.handle_update_fail_malformed_htlc(_their_node_id_conv, _msg_hu_conv);
291 public void handle_commitment_signed(long _their_node_id, long _msg) {
292 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
293 org.ldk.structs.CommitmentSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, _msg); }
294 arg.handle_commitment_signed(_their_node_id_conv, _msg_hu_conv);
297 public void handle_revoke_and_ack(long _their_node_id, long _msg) {
298 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
299 org.ldk.structs.RevokeAndACK _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, _msg); }
300 arg.handle_revoke_and_ack(_their_node_id_conv, _msg_hu_conv);
303 public void handle_update_fee(long _their_node_id, long _msg) {
304 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
305 org.ldk.structs.UpdateFee _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFee(null, _msg); }
306 arg.handle_update_fee(_their_node_id_conv, _msg_hu_conv);
309 public void handle_announcement_signatures(long _their_node_id, long _msg) {
310 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
311 org.ldk.structs.AnnouncementSignatures _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, _msg); }
312 arg.handle_announcement_signatures(_their_node_id_conv, _msg_hu_conv);
315 public void peer_disconnected(long _their_node_id) {
316 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
317 arg.peer_disconnected(_their_node_id_conv);
320 public long peer_connected(long _their_node_id, long _msg, bool _inbound) {
321 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
322 org.ldk.structs.Init _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Init(null, _msg); }
323 Result_NoneNoneZ ret = arg.peer_connected(_their_node_id_conv, _msg_hu_conv, _inbound);
325 long result = ret.clone_ptr();
328 public void handle_channel_reestablish(long _their_node_id, long _msg) {
329 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
330 org.ldk.structs.ChannelReestablish _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, _msg); }
331 arg.handle_channel_reestablish(_their_node_id_conv, _msg_hu_conv);
334 public void handle_channel_update(long _their_node_id, long _msg) {
335 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
336 org.ldk.structs.ChannelUpdate _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, _msg); }
337 arg.handle_channel_update(_their_node_id_conv, _msg_hu_conv);
340 public void handle_error(long _their_node_id, long _msg) {
341 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
342 org.ldk.structs.ErrorMessage _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ErrorMessage(null, _msg); }
343 arg.handle_error(_their_node_id_conv, _msg_hu_conv);
346 public long provided_node_features() {
347 NodeFeatures ret = arg.provided_node_features();
349 long result = ret.clone_ptr();
352 public long provided_init_features(long _their_node_id) {
353 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
354 InitFeatures ret = arg.provided_init_features(_their_node_id_conv);
356 long result = ret.clone_ptr();
359 public long get_chain_hashes() {
360 Option_CVec_ThirtyTwoBytesZZ ret = arg.get_chain_hashes();
362 long result = ret.clone_ptr();
363 if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
368 /** Creates a new instance of ChannelMessageHandler from a given implementation */
369 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProviderInterface messageSendEventsProvider_impl) {
370 LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
371 LDKChannelMessageHandlerImpl impl = new LDKChannelMessageHandlerImpl(arg, impl_holder);
372 MessageSendEventsProvider messageSendEventsProvider = MessageSendEventsProvider.new_impl(messageSendEventsProvider_impl);
373 long[] ptr_idx = bindings.LDKChannelMessageHandler_new(impl, messageSendEventsProvider.instance_idx);
375 impl_holder.held = new ChannelMessageHandler(null, ptr_idx[0]);
376 impl_holder.held.instance_idx = ptr_idx[1];
377 impl_holder.held.bindings_instance = impl;
378 impl_holder.held.ptrs_to.AddLast(messageSendEventsProvider);
379 return impl_holder.held;
383 * Handle an incoming `open_channel` message from the given peer.
385 public void handle_open_channel(byte[] their_node_id, org.ldk.structs.OpenChannel msg) {
386 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
388 GC.KeepAlive(their_node_id);
390 if (this != null) { this.ptrs_to.AddLast(msg); };
394 * Handle an incoming `open_channel2` message from the given peer.
396 public void handle_open_channel_v2(byte[] their_node_id, org.ldk.structs.OpenChannelV2 msg) {
397 bindings.ChannelMessageHandler_handle_open_channel_v2(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
399 GC.KeepAlive(their_node_id);
401 if (this != null) { this.ptrs_to.AddLast(msg); };
405 * Handle an incoming `accept_channel` message from the given peer.
407 public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.AcceptChannel msg) {
408 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
410 GC.KeepAlive(their_node_id);
412 if (this != null) { this.ptrs_to.AddLast(msg); };
416 * Handle an incoming `accept_channel2` message from the given peer.
418 public void handle_accept_channel_v2(byte[] their_node_id, org.ldk.structs.AcceptChannelV2 msg) {
419 bindings.ChannelMessageHandler_handle_accept_channel_v2(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
421 GC.KeepAlive(their_node_id);
423 if (this != null) { this.ptrs_to.AddLast(msg); };
427 * Handle an incoming `funding_created` message from the given peer.
429 public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
430 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
432 GC.KeepAlive(their_node_id);
434 if (this != null) { this.ptrs_to.AddLast(msg); };
438 * Handle an incoming `funding_signed` message from the given peer.
440 public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
441 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
443 GC.KeepAlive(their_node_id);
445 if (this != null) { this.ptrs_to.AddLast(msg); };
449 * Handle an incoming `channel_ready` message from the given peer.
451 public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
452 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
454 GC.KeepAlive(their_node_id);
456 if (this != null) { this.ptrs_to.AddLast(msg); };
460 * Handle an incoming `shutdown` message from the given peer.
462 public void handle_shutdown(byte[] their_node_id, org.ldk.structs.Shutdown msg) {
463 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
465 GC.KeepAlive(their_node_id);
467 if (this != null) { this.ptrs_to.AddLast(msg); };
471 * Handle an incoming `closing_signed` message from the given peer.
473 public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
474 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
476 GC.KeepAlive(their_node_id);
478 if (this != null) { this.ptrs_to.AddLast(msg); };
482 * Handle an incoming `stfu` message from the given peer.
484 public void handle_stfu(byte[] their_node_id, org.ldk.structs.Stfu msg) {
485 bindings.ChannelMessageHandler_handle_stfu(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
487 GC.KeepAlive(their_node_id);
489 if (this != null) { this.ptrs_to.AddLast(msg); };
493 * Handle an incoming `tx_add_input message` from the given peer.
495 public void handle_tx_add_input(byte[] their_node_id, org.ldk.structs.TxAddInput msg) {
496 bindings.ChannelMessageHandler_handle_tx_add_input(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
498 GC.KeepAlive(their_node_id);
500 if (this != null) { this.ptrs_to.AddLast(msg); };
504 * Handle an incoming `tx_add_output` message from the given peer.
506 public void handle_tx_add_output(byte[] their_node_id, org.ldk.structs.TxAddOutput msg) {
507 bindings.ChannelMessageHandler_handle_tx_add_output(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
509 GC.KeepAlive(their_node_id);
511 if (this != null) { this.ptrs_to.AddLast(msg); };
515 * Handle an incoming `tx_remove_input` message from the given peer.
517 public void handle_tx_remove_input(byte[] their_node_id, org.ldk.structs.TxRemoveInput msg) {
518 bindings.ChannelMessageHandler_handle_tx_remove_input(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
520 GC.KeepAlive(their_node_id);
522 if (this != null) { this.ptrs_to.AddLast(msg); };
526 * Handle an incoming `tx_remove_output` message from the given peer.
528 public void handle_tx_remove_output(byte[] their_node_id, org.ldk.structs.TxRemoveOutput msg) {
529 bindings.ChannelMessageHandler_handle_tx_remove_output(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
531 GC.KeepAlive(their_node_id);
533 if (this != null) { this.ptrs_to.AddLast(msg); };
537 * Handle an incoming `tx_complete message` from the given peer.
539 public void handle_tx_complete(byte[] their_node_id, org.ldk.structs.TxComplete msg) {
540 bindings.ChannelMessageHandler_handle_tx_complete(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
542 GC.KeepAlive(their_node_id);
544 if (this != null) { this.ptrs_to.AddLast(msg); };
548 * Handle an incoming `tx_signatures` message from the given peer.
550 public void handle_tx_signatures(byte[] their_node_id, org.ldk.structs.TxSignatures msg) {
551 bindings.ChannelMessageHandler_handle_tx_signatures(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
553 GC.KeepAlive(their_node_id);
555 if (this != null) { this.ptrs_to.AddLast(msg); };
559 * Handle an incoming `tx_init_rbf` message from the given peer.
561 public void handle_tx_init_rbf(byte[] their_node_id, org.ldk.structs.TxInitRbf msg) {
562 bindings.ChannelMessageHandler_handle_tx_init_rbf(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
564 GC.KeepAlive(their_node_id);
566 if (this != null) { this.ptrs_to.AddLast(msg); };
570 * Handle an incoming `tx_ack_rbf` message from the given peer.
572 public void handle_tx_ack_rbf(byte[] their_node_id, org.ldk.structs.TxAckRbf msg) {
573 bindings.ChannelMessageHandler_handle_tx_ack_rbf(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
575 GC.KeepAlive(their_node_id);
577 if (this != null) { this.ptrs_to.AddLast(msg); };
581 * Handle an incoming `tx_abort message` from the given peer.
583 public void handle_tx_abort(byte[] their_node_id, org.ldk.structs.TxAbort msg) {
584 bindings.ChannelMessageHandler_handle_tx_abort(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
586 GC.KeepAlive(their_node_id);
588 if (this != null) { this.ptrs_to.AddLast(msg); };
592 * Handle an incoming `update_add_htlc` message from the given peer.
594 public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
595 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
597 GC.KeepAlive(their_node_id);
599 if (this != null) { this.ptrs_to.AddLast(msg); };
603 * Handle an incoming `update_fulfill_htlc` message from the given peer.
605 public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
606 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
608 GC.KeepAlive(their_node_id);
610 if (this != null) { this.ptrs_to.AddLast(msg); };
614 * Handle an incoming `update_fail_htlc` message from the given peer.
616 public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
617 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
619 GC.KeepAlive(their_node_id);
621 if (this != null) { this.ptrs_to.AddLast(msg); };
625 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
627 public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
628 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
630 GC.KeepAlive(their_node_id);
632 if (this != null) { this.ptrs_to.AddLast(msg); };
636 * Handle an incoming `commitment_signed` message from the given peer.
638 public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
639 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
641 GC.KeepAlive(their_node_id);
643 if (this != null) { this.ptrs_to.AddLast(msg); };
647 * Handle an incoming `revoke_and_ack` message from the given peer.
649 public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
650 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
652 GC.KeepAlive(their_node_id);
654 if (this != null) { this.ptrs_to.AddLast(msg); };
658 * Handle an incoming `update_fee` message from the given peer.
660 public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
661 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
663 GC.KeepAlive(their_node_id);
665 if (this != null) { this.ptrs_to.AddLast(msg); };
669 * Handle an incoming `announcement_signatures` message from the given peer.
671 public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
672 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
674 GC.KeepAlive(their_node_id);
676 if (this != null) { this.ptrs_to.AddLast(msg); };
680 * Indicates a connection to the peer failed/an existing connection was lost.
682 public void peer_disconnected(byte[] their_node_id) {
683 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
685 GC.KeepAlive(their_node_id);
689 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
691 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
692 * with us. Implementors should be somewhat conservative about doing so, however, as other
693 * message handlers may still wish to communicate with this peer.
695 public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg, bool inbound) {
696 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr, inbound);
698 GC.KeepAlive(their_node_id);
700 GC.KeepAlive(inbound);
701 if (ret >= 0 && ret <= 4096) { return null; }
702 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
703 if (this != null) { this.ptrs_to.AddLast(msg); };
708 * Handle an incoming `channel_reestablish` message from the given peer.
710 public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
711 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
713 GC.KeepAlive(their_node_id);
715 if (this != null) { this.ptrs_to.AddLast(msg); };
719 * Handle an incoming `channel_update` message from the given peer.
721 public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
722 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
724 GC.KeepAlive(their_node_id);
726 if (this != null) { this.ptrs_to.AddLast(msg); };
730 * Handle an incoming `error` message from the given peer.
732 public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
733 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg.ptr);
735 GC.KeepAlive(their_node_id);
737 if (this != null) { this.ptrs_to.AddLast(msg); };
741 * Gets the node feature flags which this handler itself supports. All available handlers are
742 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
743 * which are broadcasted in our [`NodeAnnouncement`] message.
745 public NodeFeatures provided_node_features() {
746 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
748 if (ret >= 0 && ret <= 4096) { return null; }
749 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
750 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
755 * Gets the init feature flags which should be sent to the given peer. All available handlers
756 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
757 * which are sent in our [`Init`] message.
759 * Note that this method is called before [`Self::peer_connected`].
761 public InitFeatures provided_init_features(byte[] their_node_id) {
762 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
764 GC.KeepAlive(their_node_id);
765 if (ret >= 0 && ret <= 4096) { return null; }
766 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
767 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
772 * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
774 * If it's `None`, then no particular network chain hash compatibility will be enforced when
775 * connecting to peers.
777 public Option_CVec_ThirtyTwoBytesZZ get_chain_hashes() {
778 long ret = bindings.ChannelMessageHandler_get_chain_hashes(this.ptr);
780 if (ret >= 0 && ret <= 4096) { return null; }
781 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
782 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };