535c80c709d594fc056d9a16ce70ec062d47037b
[ldk-java] / src / main / java / org / ldk / structs / MessageSendEvent.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An event generated by ChannelManager which indicates a message should be sent to a peer (or
13  * broadcast to most peers).
14  * These events are handled by PeerManager::process_events if you are using a PeerManager.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class MessageSendEvent extends CommonBase {
18         private MessageSendEvent(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.MessageSendEvent_free(ptr); }
23         }
24         static MessageSendEvent constr_from_ptr(long ptr) {
25                 bindings.LDKMessageSendEvent raw_val = bindings.LDKMessageSendEvent_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendAcceptChannel.class) {
27                         return new SendAcceptChannel(ptr, (bindings.LDKMessageSendEvent.SendAcceptChannel)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendOpenChannel.class) {
30                         return new SendOpenChannel(ptr, (bindings.LDKMessageSendEvent.SendOpenChannel)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendFundingCreated.class) {
33                         return new SendFundingCreated(ptr, (bindings.LDKMessageSendEvent.SendFundingCreated)raw_val);
34                 }
35                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendFundingSigned.class) {
36                         return new SendFundingSigned(ptr, (bindings.LDKMessageSendEvent.SendFundingSigned)raw_val);
37                 }
38                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendFundingLocked.class) {
39                         return new SendFundingLocked(ptr, (bindings.LDKMessageSendEvent.SendFundingLocked)raw_val);
40                 }
41                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendAnnouncementSignatures.class) {
42                         return new SendAnnouncementSignatures(ptr, (bindings.LDKMessageSendEvent.SendAnnouncementSignatures)raw_val);
43                 }
44                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.UpdateHTLCs.class) {
45                         return new UpdateHTLCs(ptr, (bindings.LDKMessageSendEvent.UpdateHTLCs)raw_val);
46                 }
47                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendRevokeAndACK.class) {
48                         return new SendRevokeAndACK(ptr, (bindings.LDKMessageSendEvent.SendRevokeAndACK)raw_val);
49                 }
50                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendClosingSigned.class) {
51                         return new SendClosingSigned(ptr, (bindings.LDKMessageSendEvent.SendClosingSigned)raw_val);
52                 }
53                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendShutdown.class) {
54                         return new SendShutdown(ptr, (bindings.LDKMessageSendEvent.SendShutdown)raw_val);
55                 }
56                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendChannelReestablish.class) {
57                         return new SendChannelReestablish(ptr, (bindings.LDKMessageSendEvent.SendChannelReestablish)raw_val);
58                 }
59                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement.class) {
60                         return new BroadcastChannelAnnouncement(ptr, (bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement)raw_val);
61                 }
62                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement.class) {
63                         return new BroadcastNodeAnnouncement(ptr, (bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement)raw_val);
64                 }
65                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastChannelUpdate.class) {
66                         return new BroadcastChannelUpdate(ptr, (bindings.LDKMessageSendEvent.BroadcastChannelUpdate)raw_val);
67                 }
68                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendChannelUpdate.class) {
69                         return new SendChannelUpdate(ptr, (bindings.LDKMessageSendEvent.SendChannelUpdate)raw_val);
70                 }
71                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.HandleError.class) {
72                         return new HandleError(ptr, (bindings.LDKMessageSendEvent.HandleError)raw_val);
73                 }
74                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendChannelRangeQuery.class) {
75                         return new SendChannelRangeQuery(ptr, (bindings.LDKMessageSendEvent.SendChannelRangeQuery)raw_val);
76                 }
77                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendShortIdsQuery.class) {
78                         return new SendShortIdsQuery(ptr, (bindings.LDKMessageSendEvent.SendShortIdsQuery)raw_val);
79                 }
80                 if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendReplyChannelRange.class) {
81                         return new SendReplyChannelRange(ptr, (bindings.LDKMessageSendEvent.SendReplyChannelRange)raw_val);
82                 }
83                 assert false; return null; // Unreachable without extending the (internal) bindings interface
84         }
85
86         /**
87          * Used to indicate that we've accepted a channel open and should send the accept_channel
88          * message provided to the given peer.
89          */
90         public final static class SendAcceptChannel extends MessageSendEvent {
91                 /**
92                  * The node_id of the node which should receive this message
93                 */
94                 public final byte[] node_id;
95                 /**
96                  * The message which should be sent.
97                 */
98                 public final AcceptChannel msg;
99                 private SendAcceptChannel(long ptr, bindings.LDKMessageSendEvent.SendAcceptChannel obj) {
100                         super(null, ptr);
101                         this.node_id = obj.node_id;
102                         long msg = obj.msg;
103                         AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new AcceptChannel(null, msg); }
104                         msg_hu_conv.ptrs_to.add(this);
105                         this.msg = msg_hu_conv;
106                 }
107         }
108         /**
109          * Used to indicate that we've initiated a channel open and should send the open_channel
110          * message provided to the given peer.
111          */
112         public final static class SendOpenChannel extends MessageSendEvent {
113                 /**
114                  * The node_id of the node which should receive this message
115                 */
116                 public final byte[] node_id;
117                 /**
118                  * The message which should be sent.
119                 */
120                 public final OpenChannel msg;
121                 private SendOpenChannel(long ptr, bindings.LDKMessageSendEvent.SendOpenChannel obj) {
122                         super(null, ptr);
123                         this.node_id = obj.node_id;
124                         long msg = obj.msg;
125                         OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new OpenChannel(null, msg); }
126                         msg_hu_conv.ptrs_to.add(this);
127                         this.msg = msg_hu_conv;
128                 }
129         }
130         /**
131          * Used to indicate that a funding_created message should be sent to the peer with the given node_id.
132          */
133         public final static class SendFundingCreated extends MessageSendEvent {
134                 /**
135                  * The node_id of the node which should receive this message
136                 */
137                 public final byte[] node_id;
138                 /**
139                  * The message which should be sent.
140                 */
141                 public final FundingCreated msg;
142                 private SendFundingCreated(long ptr, bindings.LDKMessageSendEvent.SendFundingCreated obj) {
143                         super(null, ptr);
144                         this.node_id = obj.node_id;
145                         long msg = obj.msg;
146                         FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingCreated(null, msg); }
147                         msg_hu_conv.ptrs_to.add(this);
148                         this.msg = msg_hu_conv;
149                 }
150         }
151         /**
152          * Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
153          */
154         public final static class SendFundingSigned extends MessageSendEvent {
155                 /**
156                  * The node_id of the node which should receive this message
157                 */
158                 public final byte[] node_id;
159                 /**
160                  * The message which should be sent.
161                 */
162                 public final FundingSigned msg;
163                 private SendFundingSigned(long ptr, bindings.LDKMessageSendEvent.SendFundingSigned obj) {
164                         super(null, ptr);
165                         this.node_id = obj.node_id;
166                         long msg = obj.msg;
167                         FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingSigned(null, msg); }
168                         msg_hu_conv.ptrs_to.add(this);
169                         this.msg = msg_hu_conv;
170                 }
171         }
172         /**
173          * Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
174          */
175         public final static class SendFundingLocked extends MessageSendEvent {
176                 /**
177                  * The node_id of the node which should receive these message(s)
178                 */
179                 public final byte[] node_id;
180                 /**
181                  * The funding_locked message which should be sent.
182                 */
183                 public final FundingLocked msg;
184                 private SendFundingLocked(long ptr, bindings.LDKMessageSendEvent.SendFundingLocked obj) {
185                         super(null, ptr);
186                         this.node_id = obj.node_id;
187                         long msg = obj.msg;
188                         FundingLocked msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingLocked(null, msg); }
189                         msg_hu_conv.ptrs_to.add(this);
190                         this.msg = msg_hu_conv;
191                 }
192         }
193         /**
194          * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
195          */
196         public final static class SendAnnouncementSignatures extends MessageSendEvent {
197                 /**
198                  * The node_id of the node which should receive these message(s)
199                 */
200                 public final byte[] node_id;
201                 /**
202                  * The announcement_signatures message which should be sent.
203                 */
204                 public final AnnouncementSignatures msg;
205                 private SendAnnouncementSignatures(long ptr, bindings.LDKMessageSendEvent.SendAnnouncementSignatures obj) {
206                         super(null, ptr);
207                         this.node_id = obj.node_id;
208                         long msg = obj.msg;
209                         AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new AnnouncementSignatures(null, msg); }
210                         msg_hu_conv.ptrs_to.add(this);
211                         this.msg = msg_hu_conv;
212                 }
213         }
214         /**
215          * Used to indicate that a series of HTLC update messages, as well as a commitment_signed
216          * message should be sent to the peer with the given node_id.
217          */
218         public final static class UpdateHTLCs extends MessageSendEvent {
219                 /**
220                  * The node_id of the node which should receive these message(s)
221                 */
222                 public final byte[] node_id;
223                 /**
224                  * The update messages which should be sent. ALL messages in the struct should be sent!
225                 */
226                 public final CommitmentUpdate updates;
227                 private UpdateHTLCs(long ptr, bindings.LDKMessageSendEvent.UpdateHTLCs obj) {
228                         super(null, ptr);
229                         this.node_id = obj.node_id;
230                         long updates = obj.updates;
231                         CommitmentUpdate updates_hu_conv = null; if (updates < 0 || updates > 4096) { updates_hu_conv = new CommitmentUpdate(null, updates); }
232                         updates_hu_conv.ptrs_to.add(this);
233                         this.updates = updates_hu_conv;
234                 }
235         }
236         /**
237          * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
238          */
239         public final static class SendRevokeAndACK extends MessageSendEvent {
240                 /**
241                  * The node_id of the node which should receive this message
242                 */
243                 public final byte[] node_id;
244                 /**
245                  * The message which should be sent.
246                 */
247                 public final RevokeAndACK msg;
248                 private SendRevokeAndACK(long ptr, bindings.LDKMessageSendEvent.SendRevokeAndACK obj) {
249                         super(null, ptr);
250                         this.node_id = obj.node_id;
251                         long msg = obj.msg;
252                         RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new RevokeAndACK(null, msg); }
253                         msg_hu_conv.ptrs_to.add(this);
254                         this.msg = msg_hu_conv;
255                 }
256         }
257         /**
258          * Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
259          */
260         public final static class SendClosingSigned extends MessageSendEvent {
261                 /**
262                  * The node_id of the node which should receive this message
263                 */
264                 public final byte[] node_id;
265                 /**
266                  * The message which should be sent.
267                 */
268                 public final ClosingSigned msg;
269                 private SendClosingSigned(long ptr, bindings.LDKMessageSendEvent.SendClosingSigned obj) {
270                         super(null, ptr);
271                         this.node_id = obj.node_id;
272                         long msg = obj.msg;
273                         ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ClosingSigned(null, msg); }
274                         msg_hu_conv.ptrs_to.add(this);
275                         this.msg = msg_hu_conv;
276                 }
277         }
278         /**
279          * Used to indicate that a shutdown message should be sent to the peer with the given node_id.
280          */
281         public final static class SendShutdown extends MessageSendEvent {
282                 /**
283                  * The node_id of the node which should receive this message
284                 */
285                 public final byte[] node_id;
286                 /**
287                  * The message which should be sent.
288                 */
289                 public final Shutdown msg;
290                 private SendShutdown(long ptr, bindings.LDKMessageSendEvent.SendShutdown obj) {
291                         super(null, ptr);
292                         this.node_id = obj.node_id;
293                         long msg = obj.msg;
294                         Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new Shutdown(null, msg); }
295                         msg_hu_conv.ptrs_to.add(this);
296                         this.msg = msg_hu_conv;
297                 }
298         }
299         /**
300          * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
301          */
302         public final static class SendChannelReestablish extends MessageSendEvent {
303                 /**
304                  * The node_id of the node which should receive this message
305                 */
306                 public final byte[] node_id;
307                 /**
308                  * The message which should be sent.
309                 */
310                 public final ChannelReestablish msg;
311                 private SendChannelReestablish(long ptr, bindings.LDKMessageSendEvent.SendChannelReestablish obj) {
312                         super(null, ptr);
313                         this.node_id = obj.node_id;
314                         long msg = obj.msg;
315                         ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelReestablish(null, msg); }
316                         msg_hu_conv.ptrs_to.add(this);
317                         this.msg = msg_hu_conv;
318                 }
319         }
320         /**
321          * Used to indicate that a channel_announcement and channel_update should be broadcast to all
322          * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
323          * 
324          * Note that after doing so, you very likely (unless you did so very recently) want to call
325          * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
326          * This ensures that any nodes which see our channel_announcement also have a relevant
327          * node_announcement, including relevant feature flags which may be important for routing
328          * through or to us.
329          */
330         public final static class BroadcastChannelAnnouncement extends MessageSendEvent {
331                 /**
332                  * The channel_announcement which should be sent.
333                 */
334                 public final ChannelAnnouncement msg;
335                 /**
336                  * The followup channel_update which should be sent.
337                 */
338                 public final ChannelUpdate update_msg;
339                 private BroadcastChannelAnnouncement(long ptr, bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement obj) {
340                         super(null, ptr);
341                         long msg = obj.msg;
342                         ChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelAnnouncement(null, msg); }
343                         msg_hu_conv.ptrs_to.add(this);
344                         this.msg = msg_hu_conv;
345                         long update_msg = obj.update_msg;
346                         ChannelUpdate update_msg_hu_conv = null; if (update_msg < 0 || update_msg > 4096) { update_msg_hu_conv = new ChannelUpdate(null, update_msg); }
347                         update_msg_hu_conv.ptrs_to.add(this);
348                         this.update_msg = update_msg_hu_conv;
349                 }
350         }
351         /**
352          * Used to indicate that a node_announcement should be broadcast to all peers.
353          */
354         public final static class BroadcastNodeAnnouncement extends MessageSendEvent {
355                 /**
356                  * The node_announcement which should be sent.
357                 */
358                 public final NodeAnnouncement msg;
359                 private BroadcastNodeAnnouncement(long ptr, bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement obj) {
360                         super(null, ptr);
361                         long msg = obj.msg;
362                         NodeAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new NodeAnnouncement(null, msg); }
363                         msg_hu_conv.ptrs_to.add(this);
364                         this.msg = msg_hu_conv;
365                 }
366         }
367         /**
368          * Used to indicate that a channel_update should be broadcast to all peers.
369          */
370         public final static class BroadcastChannelUpdate extends MessageSendEvent {
371                 /**
372                  * The channel_update which should be sent.
373                 */
374                 public final ChannelUpdate msg;
375                 private BroadcastChannelUpdate(long ptr, bindings.LDKMessageSendEvent.BroadcastChannelUpdate obj) {
376                         super(null, ptr);
377                         long msg = obj.msg;
378                         ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
379                         msg_hu_conv.ptrs_to.add(this);
380                         this.msg = msg_hu_conv;
381                 }
382         }
383         /**
384          * Used to indicate that a channel_update should be sent to a single peer.
385          * In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
386          * private channel and we shouldn't be informing all of our peers of channel parameters.
387          */
388         public final static class SendChannelUpdate extends MessageSendEvent {
389                 /**
390                  * The node_id of the node which should receive this message
391                 */
392                 public final byte[] node_id;
393                 /**
394                  * The channel_update which should be sent.
395                 */
396                 public final ChannelUpdate msg;
397                 private SendChannelUpdate(long ptr, bindings.LDKMessageSendEvent.SendChannelUpdate obj) {
398                         super(null, ptr);
399                         this.node_id = obj.node_id;
400                         long msg = obj.msg;
401                         ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
402                         msg_hu_conv.ptrs_to.add(this);
403                         this.msg = msg_hu_conv;
404                 }
405         }
406         /**
407          * Broadcast an error downstream to be handled
408          */
409         public final static class HandleError extends MessageSendEvent {
410                 /**
411                  * The node_id of the node which should receive this message
412                 */
413                 public final byte[] node_id;
414                 /**
415                  * The action which should be taken.
416                 */
417                 public final ErrorAction action;
418                 private HandleError(long ptr, bindings.LDKMessageSendEvent.HandleError obj) {
419                         super(null, ptr);
420                         this.node_id = obj.node_id;
421                         long action = obj.action;
422                         ErrorAction action_hu_conv = ErrorAction.constr_from_ptr(action);
423                         action_hu_conv.ptrs_to.add(this);
424                         this.action = action_hu_conv;
425                 }
426         }
427         /**
428          * Query a peer for channels with funding transaction UTXOs in a block range.
429          */
430         public final static class SendChannelRangeQuery extends MessageSendEvent {
431                 /**
432                  * The node_id of this message recipient
433                 */
434                 public final byte[] node_id;
435                 /**
436                  * The query_channel_range which should be sent.
437                 */
438                 public final QueryChannelRange msg;
439                 private SendChannelRangeQuery(long ptr, bindings.LDKMessageSendEvent.SendChannelRangeQuery obj) {
440                         super(null, ptr);
441                         this.node_id = obj.node_id;
442                         long msg = obj.msg;
443                         QueryChannelRange msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new QueryChannelRange(null, msg); }
444                         msg_hu_conv.ptrs_to.add(this);
445                         this.msg = msg_hu_conv;
446                 }
447         }
448         /**
449          * Request routing gossip messages from a peer for a list of channels identified by
450          * their short_channel_ids.
451          */
452         public final static class SendShortIdsQuery extends MessageSendEvent {
453                 /**
454                  * The node_id of this message recipient
455                 */
456                 public final byte[] node_id;
457                 /**
458                  * The query_short_channel_ids which should be sent.
459                 */
460                 public final QueryShortChannelIds msg;
461                 private SendShortIdsQuery(long ptr, bindings.LDKMessageSendEvent.SendShortIdsQuery obj) {
462                         super(null, ptr);
463                         this.node_id = obj.node_id;
464                         long msg = obj.msg;
465                         QueryShortChannelIds msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new QueryShortChannelIds(null, msg); }
466                         msg_hu_conv.ptrs_to.add(this);
467                         this.msg = msg_hu_conv;
468                 }
469         }
470         /**
471          * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
472          * emitted during processing of the query.
473          */
474         public final static class SendReplyChannelRange extends MessageSendEvent {
475                 /**
476                  * The node_id of this message recipient
477                 */
478                 public final byte[] node_id;
479                 /**
480                  * The reply_channel_range which should be sent.
481                 */
482                 public final ReplyChannelRange msg;
483                 private SendReplyChannelRange(long ptr, bindings.LDKMessageSendEvent.SendReplyChannelRange obj) {
484                         super(null, ptr);
485                         this.node_id = obj.node_id;
486                         long msg = obj.msg;
487                         ReplyChannelRange msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ReplyChannelRange(null, msg); }
488                         msg_hu_conv.ptrs_to.add(this);
489                         this.msg = msg_hu_conv;
490                 }
491         }
492         long clone_ptr() {
493                 long ret = bindings.MessageSendEvent_clone_ptr(this.ptr);
494                 Reference.reachabilityFence(this);
495                 return ret;
496         }
497
498         /**
499          * Creates a copy of the MessageSendEvent
500          */
501         public MessageSendEvent clone() {
502                 long ret = bindings.MessageSendEvent_clone(this.ptr);
503                 Reference.reachabilityFence(this);
504                 if (ret >= 0 && ret <= 4096) { return null; }
505                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
506                 ret_hu_conv.ptrs_to.add(this);
507                 return ret_hu_conv;
508         }
509
510         /**
511          * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
512          */
513         public static MessageSendEvent send_accept_channel(byte[] node_id, AcceptChannel msg) {
514                 long ret = bindings.MessageSendEvent_send_accept_channel(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
515                 Reference.reachabilityFence(node_id);
516                 Reference.reachabilityFence(msg);
517                 if (ret >= 0 && ret <= 4096) { return null; }
518                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
519                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
520                 return ret_hu_conv;
521         }
522
523         /**
524          * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
525          */
526         public static MessageSendEvent send_open_channel(byte[] node_id, OpenChannel msg) {
527                 long ret = bindings.MessageSendEvent_send_open_channel(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
528                 Reference.reachabilityFence(node_id);
529                 Reference.reachabilityFence(msg);
530                 if (ret >= 0 && ret <= 4096) { return null; }
531                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
532                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
533                 return ret_hu_conv;
534         }
535
536         /**
537          * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
538          */
539         public static MessageSendEvent send_funding_created(byte[] node_id, FundingCreated msg) {
540                 long ret = bindings.MessageSendEvent_send_funding_created(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
541                 Reference.reachabilityFence(node_id);
542                 Reference.reachabilityFence(msg);
543                 if (ret >= 0 && ret <= 4096) { return null; }
544                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
545                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
546                 return ret_hu_conv;
547         }
548
549         /**
550          * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
551          */
552         public static MessageSendEvent send_funding_signed(byte[] node_id, FundingSigned msg) {
553                 long ret = bindings.MessageSendEvent_send_funding_signed(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
554                 Reference.reachabilityFence(node_id);
555                 Reference.reachabilityFence(msg);
556                 if (ret >= 0 && ret <= 4096) { return null; }
557                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
558                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
559                 return ret_hu_conv;
560         }
561
562         /**
563          * Utility method to constructs a new SendFundingLocked-variant MessageSendEvent
564          */
565         public static MessageSendEvent send_funding_locked(byte[] node_id, FundingLocked msg) {
566                 long ret = bindings.MessageSendEvent_send_funding_locked(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
567                 Reference.reachabilityFence(node_id);
568                 Reference.reachabilityFence(msg);
569                 if (ret >= 0 && ret <= 4096) { return null; }
570                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
571                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
572                 return ret_hu_conv;
573         }
574
575         /**
576          * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
577          */
578         public static MessageSendEvent send_announcement_signatures(byte[] node_id, AnnouncementSignatures msg) {
579                 long ret = bindings.MessageSendEvent_send_announcement_signatures(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
580                 Reference.reachabilityFence(node_id);
581                 Reference.reachabilityFence(msg);
582                 if (ret >= 0 && ret <= 4096) { return null; }
583                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
584                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
585                 return ret_hu_conv;
586         }
587
588         /**
589          * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
590          */
591         public static MessageSendEvent update_htlcs(byte[] node_id, CommitmentUpdate updates) {
592                 long ret = bindings.MessageSendEvent_update_htlcs(InternalUtils.check_arr_len(node_id, 33), updates == null ? 0 : updates.ptr & ~1);
593                 Reference.reachabilityFence(node_id);
594                 Reference.reachabilityFence(updates);
595                 if (ret >= 0 && ret <= 4096) { return null; }
596                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
597                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
598                 return ret_hu_conv;
599         }
600
601         /**
602          * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
603          */
604         public static MessageSendEvent send_revoke_and_ack(byte[] node_id, RevokeAndACK msg) {
605                 long ret = bindings.MessageSendEvent_send_revoke_and_ack(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
606                 Reference.reachabilityFence(node_id);
607                 Reference.reachabilityFence(msg);
608                 if (ret >= 0 && ret <= 4096) { return null; }
609                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
610                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
611                 return ret_hu_conv;
612         }
613
614         /**
615          * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
616          */
617         public static MessageSendEvent send_closing_signed(byte[] node_id, ClosingSigned msg) {
618                 long ret = bindings.MessageSendEvent_send_closing_signed(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
619                 Reference.reachabilityFence(node_id);
620                 Reference.reachabilityFence(msg);
621                 if (ret >= 0 && ret <= 4096) { return null; }
622                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
623                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
624                 return ret_hu_conv;
625         }
626
627         /**
628          * Utility method to constructs a new SendShutdown-variant MessageSendEvent
629          */
630         public static MessageSendEvent send_shutdown(byte[] node_id, Shutdown msg) {
631                 long ret = bindings.MessageSendEvent_send_shutdown(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
632                 Reference.reachabilityFence(node_id);
633                 Reference.reachabilityFence(msg);
634                 if (ret >= 0 && ret <= 4096) { return null; }
635                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
636                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
637                 return ret_hu_conv;
638         }
639
640         /**
641          * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent
642          */
643         public static MessageSendEvent send_channel_reestablish(byte[] node_id, ChannelReestablish msg) {
644                 long ret = bindings.MessageSendEvent_send_channel_reestablish(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
645                 Reference.reachabilityFence(node_id);
646                 Reference.reachabilityFence(msg);
647                 if (ret >= 0 && ret <= 4096) { return null; }
648                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
649                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
650                 return ret_hu_conv;
651         }
652
653         /**
654          * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
655          */
656         public static MessageSendEvent broadcast_channel_announcement(ChannelAnnouncement msg, ChannelUpdate update_msg) {
657                 long ret = bindings.MessageSendEvent_broadcast_channel_announcement(msg == null ? 0 : msg.ptr & ~1, update_msg == null ? 0 : update_msg.ptr & ~1);
658                 Reference.reachabilityFence(msg);
659                 Reference.reachabilityFence(update_msg);
660                 if (ret >= 0 && ret <= 4096) { return null; }
661                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
662                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
663                 return ret_hu_conv;
664         }
665
666         /**
667          * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
668          */
669         public static MessageSendEvent broadcast_node_announcement(NodeAnnouncement msg) {
670                 long ret = bindings.MessageSendEvent_broadcast_node_announcement(msg == null ? 0 : msg.ptr & ~1);
671                 Reference.reachabilityFence(msg);
672                 if (ret >= 0 && ret <= 4096) { return null; }
673                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
674                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
675                 return ret_hu_conv;
676         }
677
678         /**
679          * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
680          */
681         public static MessageSendEvent broadcast_channel_update(ChannelUpdate msg) {
682                 long ret = bindings.MessageSendEvent_broadcast_channel_update(msg == null ? 0 : msg.ptr & ~1);
683                 Reference.reachabilityFence(msg);
684                 if (ret >= 0 && ret <= 4096) { return null; }
685                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
686                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
687                 return ret_hu_conv;
688         }
689
690         /**
691          * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent
692          */
693         public static MessageSendEvent send_channel_update(byte[] node_id, ChannelUpdate msg) {
694                 long ret = bindings.MessageSendEvent_send_channel_update(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
695                 Reference.reachabilityFence(node_id);
696                 Reference.reachabilityFence(msg);
697                 if (ret >= 0 && ret <= 4096) { return null; }
698                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
699                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
700                 return ret_hu_conv;
701         }
702
703         /**
704          * Utility method to constructs a new HandleError-variant MessageSendEvent
705          */
706         public static MessageSendEvent handle_error(byte[] node_id, ErrorAction action) {
707                 long ret = bindings.MessageSendEvent_handle_error(InternalUtils.check_arr_len(node_id, 33), action.ptr);
708                 Reference.reachabilityFence(node_id);
709                 Reference.reachabilityFence(action);
710                 if (ret >= 0 && ret <= 4096) { return null; }
711                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
712                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
713                 return ret_hu_conv;
714         }
715
716         /**
717          * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
718          */
719         public static MessageSendEvent send_channel_range_query(byte[] node_id, QueryChannelRange msg) {
720                 long ret = bindings.MessageSendEvent_send_channel_range_query(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
721                 Reference.reachabilityFence(node_id);
722                 Reference.reachabilityFence(msg);
723                 if (ret >= 0 && ret <= 4096) { return null; }
724                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
725                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
726                 return ret_hu_conv;
727         }
728
729         /**
730          * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent
731          */
732         public static MessageSendEvent send_short_ids_query(byte[] node_id, QueryShortChannelIds msg) {
733                 long ret = bindings.MessageSendEvent_send_short_ids_query(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
734                 Reference.reachabilityFence(node_id);
735                 Reference.reachabilityFence(msg);
736                 if (ret >= 0 && ret <= 4096) { return null; }
737                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
738                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
739                 return ret_hu_conv;
740         }
741
742         /**
743          * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent
744          */
745         public static MessageSendEvent send_reply_channel_range(byte[] node_id, ReplyChannelRange msg) {
746                 long ret = bindings.MessageSendEvent_send_reply_channel_range(InternalUtils.check_arr_len(node_id, 33), msg == null ? 0 : msg.ptr & ~1);
747                 Reference.reachabilityFence(node_id);
748                 Reference.reachabilityFence(msg);
749                 if (ret >= 0 && ret <= 4096) { return null; }
750                 MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
751                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
752                 return ret_hu_conv;
753         }
754
755 }