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 `tx_add_input message` from the given peer.
42 void handle_tx_add_input(byte[] their_node_id, TxAddInput msg);
43 /**Handle an incoming `tx_add_output` message from the given peer.
45 void handle_tx_add_output(byte[] their_node_id, TxAddOutput msg);
46 /**Handle an incoming `tx_remove_input` message from the given peer.
48 void handle_tx_remove_input(byte[] their_node_id, TxRemoveInput msg);
49 /**Handle an incoming `tx_remove_output` message from the given peer.
51 void handle_tx_remove_output(byte[] their_node_id, TxRemoveOutput msg);
52 /**Handle an incoming `tx_complete message` from the given peer.
54 void handle_tx_complete(byte[] their_node_id, TxComplete msg);
55 /**Handle an incoming `tx_signatures` message from the given peer.
57 void handle_tx_signatures(byte[] their_node_id, TxSignatures msg);
58 /**Handle an incoming `tx_init_rbf` message from the given peer.
60 void handle_tx_init_rbf(byte[] their_node_id, TxInitRbf msg);
61 /**Handle an incoming `tx_ack_rbf` message from the given peer.
63 void handle_tx_ack_rbf(byte[] their_node_id, TxAckRbf msg);
64 /**Handle an incoming `tx_abort message` from the given peer.
66 void handle_tx_abort(byte[] their_node_id, TxAbort msg);
67 /**Handle an incoming `update_add_htlc` message from the given peer.
69 void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg);
70 /**Handle an incoming `update_fulfill_htlc` message from the given peer.
72 void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg);
73 /**Handle an incoming `update_fail_htlc` message from the given peer.
75 void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg);
76 /**Handle an incoming `update_fail_malformed_htlc` message from the given peer.
78 void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg);
79 /**Handle an incoming `commitment_signed` message from the given peer.
81 void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg);
82 /**Handle an incoming `revoke_and_ack` message from the given peer.
84 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);
88 /**Handle an incoming `announcement_signatures` message from the given peer.
90 void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg);
91 /**Indicates a connection to the peer failed/an existing connection was lost.
93 void peer_disconnected(byte[] their_node_id);
94 /**Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
96 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
97 * with us. Implementors should be somewhat conservative about doing so, however, as other
98 * message handlers may still wish to communicate with this peer.
100 Result_NoneNoneZ peer_connected(byte[] their_node_id, Init msg, bool inbound);
101 /**Handle an incoming `channel_reestablish` message from the given peer.
103 void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg);
104 /**Handle an incoming `channel_update` message from the given peer.
106 void handle_channel_update(byte[] their_node_id, ChannelUpdate msg);
107 /**Handle an incoming `error` message from the given peer.
109 void handle_error(byte[] their_node_id, ErrorMessage msg);
110 /**Gets the node feature flags which this handler itself supports. All available handlers are
111 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
112 * which are broadcasted in our [`NodeAnnouncement`] message.
114 NodeFeatures provided_node_features();
115 /**Gets the init feature flags which should be sent to the given peer. All available handlers
116 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
117 * which are sent in our [`Init`] message.
119 * Note that this method is called before [`Self::peer_connected`].
121 InitFeatures provided_init_features(byte[] their_node_id);
122 /**Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
124 * If it's `None`, then no particular network chain hash compatibility will be enforced when
125 * connecting to peers.
127 Option_CVec_ThirtyTwoBytesZZ get_chain_hashes();
131 * A trait to describe an object which can receive channel messages.
133 * Messages MAY be called in parallel when they originate from different `their_node_ids`, however
134 * they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
136 public class ChannelMessageHandler : CommonBase {
137 internal bindings.LDKChannelMessageHandler bindings_instance;
138 internal long instance_idx;
140 internal ChannelMessageHandler(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
141 ~ChannelMessageHandler() {
142 if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); }
145 private class LDKChannelMessageHandlerHolder { internal ChannelMessageHandler held; }
146 private class LDKChannelMessageHandlerImpl : bindings.LDKChannelMessageHandler {
147 internal LDKChannelMessageHandlerImpl(ChannelMessageHandlerInterface arg, LDKChannelMessageHandlerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
148 private ChannelMessageHandlerInterface arg;
149 private LDKChannelMessageHandlerHolder impl_holder;
150 public void handle_open_channel(long _their_node_id, long _msg) {
151 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
152 org.ldk.structs.OpenChannel _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.OpenChannel(null, _msg); }
153 arg.handle_open_channel(_their_node_id_conv, _msg_hu_conv);
156 public void handle_open_channel_v2(long _their_node_id, long _msg) {
157 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
158 org.ldk.structs.OpenChannelV2 _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.OpenChannelV2(null, _msg); }
159 arg.handle_open_channel_v2(_their_node_id_conv, _msg_hu_conv);
162 public void handle_accept_channel(long _their_node_id, long _msg) {
163 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
164 org.ldk.structs.AcceptChannel _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AcceptChannel(null, _msg); }
165 arg.handle_accept_channel(_their_node_id_conv, _msg_hu_conv);
168 public void handle_accept_channel_v2(long _their_node_id, long _msg) {
169 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
170 org.ldk.structs.AcceptChannelV2 _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AcceptChannelV2(null, _msg); }
171 arg.handle_accept_channel_v2(_their_node_id_conv, _msg_hu_conv);
174 public void handle_funding_created(long _their_node_id, long _msg) {
175 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
176 org.ldk.structs.FundingCreated _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.FundingCreated(null, _msg); }
177 arg.handle_funding_created(_their_node_id_conv, _msg_hu_conv);
180 public void handle_funding_signed(long _their_node_id, long _msg) {
181 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
182 org.ldk.structs.FundingSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.FundingSigned(null, _msg); }
183 arg.handle_funding_signed(_their_node_id_conv, _msg_hu_conv);
186 public void handle_channel_ready(long _their_node_id, long _msg) {
187 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
188 org.ldk.structs.ChannelReady _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelReady(null, _msg); }
189 arg.handle_channel_ready(_their_node_id_conv, _msg_hu_conv);
192 public void handle_shutdown(long _their_node_id, long _msg) {
193 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
194 org.ldk.structs.Shutdown _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Shutdown(null, _msg); }
195 arg.handle_shutdown(_their_node_id_conv, _msg_hu_conv);
198 public void handle_closing_signed(long _their_node_id, long _msg) {
199 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
200 org.ldk.structs.ClosingSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ClosingSigned(null, _msg); }
201 arg.handle_closing_signed(_their_node_id_conv, _msg_hu_conv);
204 public void handle_tx_add_input(long _their_node_id, long _msg) {
205 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
206 org.ldk.structs.TxAddInput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAddInput(null, _msg); }
207 arg.handle_tx_add_input(_their_node_id_conv, _msg_hu_conv);
210 public void handle_tx_add_output(long _their_node_id, long _msg) {
211 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
212 org.ldk.structs.TxAddOutput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAddOutput(null, _msg); }
213 arg.handle_tx_add_output(_their_node_id_conv, _msg_hu_conv);
216 public void handle_tx_remove_input(long _their_node_id, long _msg) {
217 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
218 org.ldk.structs.TxRemoveInput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxRemoveInput(null, _msg); }
219 arg.handle_tx_remove_input(_their_node_id_conv, _msg_hu_conv);
222 public void handle_tx_remove_output(long _their_node_id, long _msg) {
223 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
224 org.ldk.structs.TxRemoveOutput _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxRemoveOutput(null, _msg); }
225 arg.handle_tx_remove_output(_their_node_id_conv, _msg_hu_conv);
228 public void handle_tx_complete(long _their_node_id, long _msg) {
229 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
230 org.ldk.structs.TxComplete _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxComplete(null, _msg); }
231 arg.handle_tx_complete(_their_node_id_conv, _msg_hu_conv);
234 public void handle_tx_signatures(long _their_node_id, long _msg) {
235 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
236 org.ldk.structs.TxSignatures _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxSignatures(null, _msg); }
237 arg.handle_tx_signatures(_their_node_id_conv, _msg_hu_conv);
240 public void handle_tx_init_rbf(long _their_node_id, long _msg) {
241 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
242 org.ldk.structs.TxInitRbf _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxInitRbf(null, _msg); }
243 arg.handle_tx_init_rbf(_their_node_id_conv, _msg_hu_conv);
246 public void handle_tx_ack_rbf(long _their_node_id, long _msg) {
247 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
248 org.ldk.structs.TxAckRbf _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAckRbf(null, _msg); }
249 arg.handle_tx_ack_rbf(_their_node_id_conv, _msg_hu_conv);
252 public void handle_tx_abort(long _their_node_id, long _msg) {
253 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
254 org.ldk.structs.TxAbort _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.TxAbort(null, _msg); }
255 arg.handle_tx_abort(_their_node_id_conv, _msg_hu_conv);
258 public void handle_update_add_htlc(long _their_node_id, long _msg) {
259 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
260 org.ldk.structs.UpdateAddHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, _msg); }
261 arg.handle_update_add_htlc(_their_node_id_conv, _msg_hu_conv);
264 public void handle_update_fulfill_htlc(long _their_node_id, long _msg) {
265 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
266 org.ldk.structs.UpdateFulfillHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, _msg); }
267 arg.handle_update_fulfill_htlc(_their_node_id_conv, _msg_hu_conv);
270 public void handle_update_fail_htlc(long _their_node_id, long _msg) {
271 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
272 org.ldk.structs.UpdateFailHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, _msg); }
273 arg.handle_update_fail_htlc(_their_node_id_conv, _msg_hu_conv);
276 public void handle_update_fail_malformed_htlc(long _their_node_id, long _msg) {
277 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
278 org.ldk.structs.UpdateFailMalformedHTLC _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, _msg); }
279 arg.handle_update_fail_malformed_htlc(_their_node_id_conv, _msg_hu_conv);
282 public void handle_commitment_signed(long _their_node_id, long _msg) {
283 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
284 org.ldk.structs.CommitmentSigned _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.CommitmentSigned(null, _msg); }
285 arg.handle_commitment_signed(_their_node_id_conv, _msg_hu_conv);
288 public void handle_revoke_and_ack(long _their_node_id, long _msg) {
289 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
290 org.ldk.structs.RevokeAndACK _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.RevokeAndACK(null, _msg); }
291 arg.handle_revoke_and_ack(_their_node_id_conv, _msg_hu_conv);
294 public void handle_update_fee(long _their_node_id, long _msg) {
295 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
296 org.ldk.structs.UpdateFee _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.UpdateFee(null, _msg); }
297 arg.handle_update_fee(_their_node_id_conv, _msg_hu_conv);
300 public void handle_announcement_signatures(long _their_node_id, long _msg) {
301 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
302 org.ldk.structs.AnnouncementSignatures _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.AnnouncementSignatures(null, _msg); }
303 arg.handle_announcement_signatures(_their_node_id_conv, _msg_hu_conv);
306 public void peer_disconnected(long _their_node_id) {
307 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
308 arg.peer_disconnected(_their_node_id_conv);
311 public long peer_connected(long _their_node_id, long _msg, bool _inbound) {
312 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
313 org.ldk.structs.Init _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.Init(null, _msg); }
314 Result_NoneNoneZ ret = arg.peer_connected(_their_node_id_conv, _msg_hu_conv, _inbound);
316 long result = ret == null ? 0 : ret.clone_ptr();
319 public void handle_channel_reestablish(long _their_node_id, long _msg) {
320 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
321 org.ldk.structs.ChannelReestablish _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelReestablish(null, _msg); }
322 arg.handle_channel_reestablish(_their_node_id_conv, _msg_hu_conv);
325 public void handle_channel_update(long _their_node_id, long _msg) {
326 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
327 org.ldk.structs.ChannelUpdate _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, _msg); }
328 arg.handle_channel_update(_their_node_id_conv, _msg_hu_conv);
331 public void handle_error(long _their_node_id, long _msg) {
332 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
333 org.ldk.structs.ErrorMessage _msg_hu_conv = null; if (_msg < 0 || _msg > 4096) { _msg_hu_conv = new org.ldk.structs.ErrorMessage(null, _msg); }
334 arg.handle_error(_their_node_id_conv, _msg_hu_conv);
337 public long provided_node_features() {
338 NodeFeatures ret = arg.provided_node_features();
340 long result = ret == null ? 0 : ret.clone_ptr();
343 public long provided_init_features(long _their_node_id) {
344 byte[] _their_node_id_conv = InternalUtils.decodeUint8Array(_their_node_id);
345 InitFeatures ret = arg.provided_init_features(_their_node_id_conv);
347 long result = ret == null ? 0 : ret.clone_ptr();
350 public long get_chain_hashes() {
351 Option_CVec_ThirtyTwoBytesZZ ret = arg.get_chain_hashes();
353 long result = ret == null ? 0 : ret.clone_ptr();
354 if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
359 /** Creates a new instance of ChannelMessageHandler from a given implementation */
360 public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProviderInterface messageSendEventsProvider_impl) {
361 LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
362 LDKChannelMessageHandlerImpl impl = new LDKChannelMessageHandlerImpl(arg, impl_holder);
363 MessageSendEventsProvider messageSendEventsProvider = MessageSendEventsProvider.new_impl(messageSendEventsProvider_impl);
364 long[] ptr_idx = bindings.LDKChannelMessageHandler_new(impl, messageSendEventsProvider.instance_idx);
366 impl_holder.held = new ChannelMessageHandler(null, ptr_idx[0]);
367 impl_holder.held.instance_idx = ptr_idx[1];
368 impl_holder.held.bindings_instance = impl;
369 impl_holder.held.ptrs_to.AddLast(messageSendEventsProvider);
370 return impl_holder.held;
374 * Handle an incoming `open_channel` message from the given peer.
376 public void handle_open_channel(byte[] their_node_id, org.ldk.structs.OpenChannel msg) {
377 bindings.ChannelMessageHandler_handle_open_channel(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
379 GC.KeepAlive(their_node_id);
381 if (this != null) { this.ptrs_to.AddLast(msg); };
385 * Handle an incoming `open_channel2` message from the given peer.
387 public void handle_open_channel_v2(byte[] their_node_id, org.ldk.structs.OpenChannelV2 msg) {
388 bindings.ChannelMessageHandler_handle_open_channel_v2(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
390 GC.KeepAlive(their_node_id);
392 if (this != null) { this.ptrs_to.AddLast(msg); };
396 * Handle an incoming `accept_channel` message from the given peer.
398 public void handle_accept_channel(byte[] their_node_id, org.ldk.structs.AcceptChannel msg) {
399 bindings.ChannelMessageHandler_handle_accept_channel(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
401 GC.KeepAlive(their_node_id);
403 if (this != null) { this.ptrs_to.AddLast(msg); };
407 * Handle an incoming `accept_channel2` message from the given peer.
409 public void handle_accept_channel_v2(byte[] their_node_id, org.ldk.structs.AcceptChannelV2 msg) {
410 bindings.ChannelMessageHandler_handle_accept_channel_v2(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
412 GC.KeepAlive(their_node_id);
414 if (this != null) { this.ptrs_to.AddLast(msg); };
418 * Handle an incoming `funding_created` message from the given peer.
420 public void handle_funding_created(byte[] their_node_id, org.ldk.structs.FundingCreated msg) {
421 bindings.ChannelMessageHandler_handle_funding_created(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
423 GC.KeepAlive(their_node_id);
425 if (this != null) { this.ptrs_to.AddLast(msg); };
429 * Handle an incoming `funding_signed` message from the given peer.
431 public void handle_funding_signed(byte[] their_node_id, org.ldk.structs.FundingSigned msg) {
432 bindings.ChannelMessageHandler_handle_funding_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
434 GC.KeepAlive(their_node_id);
436 if (this != null) { this.ptrs_to.AddLast(msg); };
440 * Handle an incoming `channel_ready` message from the given peer.
442 public void handle_channel_ready(byte[] their_node_id, org.ldk.structs.ChannelReady msg) {
443 bindings.ChannelMessageHandler_handle_channel_ready(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
445 GC.KeepAlive(their_node_id);
447 if (this != null) { this.ptrs_to.AddLast(msg); };
451 * Handle an incoming `shutdown` message from the given peer.
453 public void handle_shutdown(byte[] their_node_id, org.ldk.structs.Shutdown msg) {
454 bindings.ChannelMessageHandler_handle_shutdown(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
456 GC.KeepAlive(their_node_id);
458 if (this != null) { this.ptrs_to.AddLast(msg); };
462 * Handle an incoming `closing_signed` message from the given peer.
464 public void handle_closing_signed(byte[] their_node_id, org.ldk.structs.ClosingSigned msg) {
465 bindings.ChannelMessageHandler_handle_closing_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
467 GC.KeepAlive(their_node_id);
469 if (this != null) { this.ptrs_to.AddLast(msg); };
473 * Handle an incoming `tx_add_input message` from the given peer.
475 public void handle_tx_add_input(byte[] their_node_id, org.ldk.structs.TxAddInput msg) {
476 bindings.ChannelMessageHandler_handle_tx_add_input(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
478 GC.KeepAlive(their_node_id);
480 if (this != null) { this.ptrs_to.AddLast(msg); };
484 * Handle an incoming `tx_add_output` message from the given peer.
486 public void handle_tx_add_output(byte[] their_node_id, org.ldk.structs.TxAddOutput msg) {
487 bindings.ChannelMessageHandler_handle_tx_add_output(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
489 GC.KeepAlive(their_node_id);
491 if (this != null) { this.ptrs_to.AddLast(msg); };
495 * Handle an incoming `tx_remove_input` message from the given peer.
497 public void handle_tx_remove_input(byte[] their_node_id, org.ldk.structs.TxRemoveInput msg) {
498 bindings.ChannelMessageHandler_handle_tx_remove_input(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
500 GC.KeepAlive(their_node_id);
502 if (this != null) { this.ptrs_to.AddLast(msg); };
506 * Handle an incoming `tx_remove_output` message from the given peer.
508 public void handle_tx_remove_output(byte[] their_node_id, org.ldk.structs.TxRemoveOutput msg) {
509 bindings.ChannelMessageHandler_handle_tx_remove_output(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
511 GC.KeepAlive(their_node_id);
513 if (this != null) { this.ptrs_to.AddLast(msg); };
517 * Handle an incoming `tx_complete message` from the given peer.
519 public void handle_tx_complete(byte[] their_node_id, org.ldk.structs.TxComplete msg) {
520 bindings.ChannelMessageHandler_handle_tx_complete(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
522 GC.KeepAlive(their_node_id);
524 if (this != null) { this.ptrs_to.AddLast(msg); };
528 * Handle an incoming `tx_signatures` message from the given peer.
530 public void handle_tx_signatures(byte[] their_node_id, org.ldk.structs.TxSignatures msg) {
531 bindings.ChannelMessageHandler_handle_tx_signatures(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
533 GC.KeepAlive(their_node_id);
535 if (this != null) { this.ptrs_to.AddLast(msg); };
539 * Handle an incoming `tx_init_rbf` message from the given peer.
541 public void handle_tx_init_rbf(byte[] their_node_id, org.ldk.structs.TxInitRbf msg) {
542 bindings.ChannelMessageHandler_handle_tx_init_rbf(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
544 GC.KeepAlive(their_node_id);
546 if (this != null) { this.ptrs_to.AddLast(msg); };
550 * Handle an incoming `tx_ack_rbf` message from the given peer.
552 public void handle_tx_ack_rbf(byte[] their_node_id, org.ldk.structs.TxAckRbf msg) {
553 bindings.ChannelMessageHandler_handle_tx_ack_rbf(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
555 GC.KeepAlive(their_node_id);
557 if (this != null) { this.ptrs_to.AddLast(msg); };
561 * Handle an incoming `tx_abort message` from the given peer.
563 public void handle_tx_abort(byte[] their_node_id, org.ldk.structs.TxAbort msg) {
564 bindings.ChannelMessageHandler_handle_tx_abort(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
566 GC.KeepAlive(their_node_id);
568 if (this != null) { this.ptrs_to.AddLast(msg); };
572 * Handle an incoming `update_add_htlc` message from the given peer.
574 public void handle_update_add_htlc(byte[] their_node_id, org.ldk.structs.UpdateAddHTLC msg) {
575 bindings.ChannelMessageHandler_handle_update_add_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
577 GC.KeepAlive(their_node_id);
579 if (this != null) { this.ptrs_to.AddLast(msg); };
583 * Handle an incoming `update_fulfill_htlc` message from the given peer.
585 public void handle_update_fulfill_htlc(byte[] their_node_id, org.ldk.structs.UpdateFulfillHTLC msg) {
586 bindings.ChannelMessageHandler_handle_update_fulfill_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
588 GC.KeepAlive(their_node_id);
590 if (this != null) { this.ptrs_to.AddLast(msg); };
594 * Handle an incoming `update_fail_htlc` message from the given peer.
596 public void handle_update_fail_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailHTLC msg) {
597 bindings.ChannelMessageHandler_handle_update_fail_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
599 GC.KeepAlive(their_node_id);
601 if (this != null) { this.ptrs_to.AddLast(msg); };
605 * Handle an incoming `update_fail_malformed_htlc` message from the given peer.
607 public void handle_update_fail_malformed_htlc(byte[] their_node_id, org.ldk.structs.UpdateFailMalformedHTLC msg) {
608 bindings.ChannelMessageHandler_handle_update_fail_malformed_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
610 GC.KeepAlive(their_node_id);
612 if (this != null) { this.ptrs_to.AddLast(msg); };
616 * Handle an incoming `commitment_signed` message from the given peer.
618 public void handle_commitment_signed(byte[] their_node_id, org.ldk.structs.CommitmentSigned msg) {
619 bindings.ChannelMessageHandler_handle_commitment_signed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
621 GC.KeepAlive(their_node_id);
623 if (this != null) { this.ptrs_to.AddLast(msg); };
627 * Handle an incoming `revoke_and_ack` message from the given peer.
629 public void handle_revoke_and_ack(byte[] their_node_id, org.ldk.structs.RevokeAndACK msg) {
630 bindings.ChannelMessageHandler_handle_revoke_and_ack(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
632 GC.KeepAlive(their_node_id);
634 if (this != null) { this.ptrs_to.AddLast(msg); };
638 * Handle an incoming `update_fee` message from the given peer.
640 public void handle_update_fee(byte[] their_node_id, org.ldk.structs.UpdateFee msg) {
641 bindings.ChannelMessageHandler_handle_update_fee(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
643 GC.KeepAlive(their_node_id);
645 if (this != null) { this.ptrs_to.AddLast(msg); };
649 * Handle an incoming `announcement_signatures` message from the given peer.
651 public void handle_announcement_signatures(byte[] their_node_id, org.ldk.structs.AnnouncementSignatures msg) {
652 bindings.ChannelMessageHandler_handle_announcement_signatures(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
654 GC.KeepAlive(their_node_id);
656 if (this != null) { this.ptrs_to.AddLast(msg); };
660 * Indicates a connection to the peer failed/an existing connection was lost.
662 public void peer_disconnected(byte[] their_node_id) {
663 bindings.ChannelMessageHandler_peer_disconnected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
665 GC.KeepAlive(their_node_id);
669 * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
671 * May return an `Err(())` if the features the peer supports are not sufficient to communicate
672 * with us. Implementors should be somewhat conservative about doing so, however, as other
673 * message handlers may still wish to communicate with this peer.
675 public Result_NoneNoneZ peer_connected(byte[] their_node_id, org.ldk.structs.Init msg, bool inbound) {
676 long ret = bindings.ChannelMessageHandler_peer_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr, inbound);
678 GC.KeepAlive(their_node_id);
680 GC.KeepAlive(inbound);
681 if (ret >= 0 && ret <= 4096) { return null; }
682 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
683 if (this != null) { this.ptrs_to.AddLast(msg); };
688 * Handle an incoming `channel_reestablish` message from the given peer.
690 public void handle_channel_reestablish(byte[] their_node_id, org.ldk.structs.ChannelReestablish msg) {
691 bindings.ChannelMessageHandler_handle_channel_reestablish(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
693 GC.KeepAlive(their_node_id);
695 if (this != null) { this.ptrs_to.AddLast(msg); };
699 * Handle an incoming `channel_update` message from the given peer.
701 public void handle_channel_update(byte[] their_node_id, org.ldk.structs.ChannelUpdate msg) {
702 bindings.ChannelMessageHandler_handle_channel_update(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
704 GC.KeepAlive(their_node_id);
706 if (this != null) { this.ptrs_to.AddLast(msg); };
710 * Handle an incoming `error` message from the given peer.
712 public void handle_error(byte[] their_node_id, org.ldk.structs.ErrorMessage msg) {
713 bindings.ChannelMessageHandler_handle_error(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)), msg == null ? 0 : msg.ptr);
715 GC.KeepAlive(their_node_id);
717 if (this != null) { this.ptrs_to.AddLast(msg); };
721 * Gets the node feature flags which this handler itself supports. All available handlers are
722 * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
723 * which are broadcasted in our [`NodeAnnouncement`] message.
725 public NodeFeatures provided_node_features() {
726 long ret = bindings.ChannelMessageHandler_provided_node_features(this.ptr);
728 if (ret >= 0 && ret <= 4096) { return null; }
729 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
730 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
735 * Gets the init feature flags which should be sent to the given peer. All available handlers
736 * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
737 * which are sent in our [`Init`] message.
739 * Note that this method is called before [`Self::peer_connected`].
741 public InitFeatures provided_init_features(byte[] their_node_id) {
742 long ret = bindings.ChannelMessageHandler_provided_init_features(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(their_node_id, 33)));
744 GC.KeepAlive(their_node_id);
745 if (ret >= 0 && ret <= 4096) { return null; }
746 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
747 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
752 * Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
754 * If it's `None`, then no particular network chain hash compatibility will be enforced when
755 * connecting to peers.
757 public Option_CVec_ThirtyTwoBytesZZ get_chain_hashes() {
758 long ret = bindings.ChannelMessageHandler_get_chain_hashes(this.ptr);
760 if (ret >= 0 && ret <= 4096) { return null; }
761 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
762 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };