[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / UnsignedGossipMessage.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * Represents the set of gossip messages that require a signature from a node's identity key.
10  */
11 public class UnsignedGossipMessage : CommonBase {
12         protected UnsignedGossipMessage(object _dummy, long ptr) : base(ptr) { }
13         ~UnsignedGossipMessage() {
14                 if (ptr != 0) { bindings.UnsignedGossipMessage_free(ptr); }
15         }
16
17         internal static UnsignedGossipMessage constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKUnsignedGossipMessage_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new UnsignedGossipMessage_ChannelAnnouncement(ptr);
21                         case 1: return new UnsignedGossipMessage_ChannelUpdate(ptr);
22                         case 2: return new UnsignedGossipMessage_NodeAnnouncement(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A UnsignedGossipMessage of type ChannelAnnouncement */
29         public class UnsignedGossipMessage_ChannelAnnouncement : UnsignedGossipMessage {
30                 public UnsignedChannelAnnouncement channel_announcement;
31                 internal UnsignedGossipMessage_ChannelAnnouncement(long ptr) : base(null, ptr) {
32                         long channel_announcement = bindings.LDKUnsignedGossipMessage_ChannelAnnouncement_get_channel_announcement(ptr);
33                         org.ldk.structs.UnsignedChannelAnnouncement channel_announcement_hu_conv = null; if (channel_announcement < 0 || channel_announcement > 4096) { channel_announcement_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, channel_announcement); }
34                         if (channel_announcement_hu_conv != null) { channel_announcement_hu_conv.ptrs_to.AddLast(this); };
35                         this.channel_announcement = channel_announcement_hu_conv;
36                 }
37         }
38         /** A UnsignedGossipMessage of type ChannelUpdate */
39         public class UnsignedGossipMessage_ChannelUpdate : UnsignedGossipMessage {
40                 public UnsignedChannelUpdate channel_update;
41                 internal UnsignedGossipMessage_ChannelUpdate(long ptr) : base(null, ptr) {
42                         long channel_update = bindings.LDKUnsignedGossipMessage_ChannelUpdate_get_channel_update(ptr);
43                         org.ldk.structs.UnsignedChannelUpdate channel_update_hu_conv = null; if (channel_update < 0 || channel_update > 4096) { channel_update_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, channel_update); }
44                         if (channel_update_hu_conv != null) { channel_update_hu_conv.ptrs_to.AddLast(this); };
45                         this.channel_update = channel_update_hu_conv;
46                 }
47         }
48         /** A UnsignedGossipMessage of type NodeAnnouncement */
49         public class UnsignedGossipMessage_NodeAnnouncement : UnsignedGossipMessage {
50                 public UnsignedNodeAnnouncement node_announcement;
51                 internal UnsignedGossipMessage_NodeAnnouncement(long ptr) : base(null, ptr) {
52                         long node_announcement = bindings.LDKUnsignedGossipMessage_NodeAnnouncement_get_node_announcement(ptr);
53                         org.ldk.structs.UnsignedNodeAnnouncement node_announcement_hu_conv = null; if (node_announcement < 0 || node_announcement > 4096) { node_announcement_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, node_announcement); }
54                         if (node_announcement_hu_conv != null) { node_announcement_hu_conv.ptrs_to.AddLast(this); };
55                         this.node_announcement = node_announcement_hu_conv;
56                 }
57         }
58         internal long clone_ptr() {
59                 long ret = bindings.UnsignedGossipMessage_clone_ptr(this.ptr);
60                 GC.KeepAlive(this);
61                 return ret;
62         }
63
64         /**
65          * Creates a copy of the UnsignedGossipMessage
66          */
67         public UnsignedGossipMessage clone() {
68                 long ret = bindings.UnsignedGossipMessage_clone(this.ptr);
69                 GC.KeepAlive(this);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.UnsignedGossipMessage ret_hu_conv = org.ldk.structs.UnsignedGossipMessage.constr_from_ptr(ret);
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
78          */
79         public static UnsignedGossipMessage channel_announcement(org.ldk.structs.UnsignedChannelAnnouncement a) {
80                 long ret = bindings.UnsignedGossipMessage_channel_announcement(a == null ? 0 : a.ptr);
81                 GC.KeepAlive(a);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.UnsignedGossipMessage ret_hu_conv = org.ldk.structs.UnsignedGossipMessage.constr_from_ptr(ret);
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
91          */
92         public static UnsignedGossipMessage channel_update(org.ldk.structs.UnsignedChannelUpdate a) {
93                 long ret = bindings.UnsignedGossipMessage_channel_update(a == null ? 0 : a.ptr);
94                 GC.KeepAlive(a);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.UnsignedGossipMessage ret_hu_conv = org.ldk.structs.UnsignedGossipMessage.constr_from_ptr(ret);
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
104          */
105         public static UnsignedGossipMessage node_announcement(org.ldk.structs.UnsignedNodeAnnouncement a) {
106                 long ret = bindings.UnsignedGossipMessage_node_announcement(a == null ? 0 : a.ptr);
107                 GC.KeepAlive(a);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.UnsignedGossipMessage ret_hu_conv = org.ldk.structs.UnsignedGossipMessage.constr_from_ptr(ret);
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
117          */
118         public byte[] write() {
119                 long ret = bindings.UnsignedGossipMessage_write(this.ptr);
120                 GC.KeepAlive(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
123                 return ret_conv;
124         }
125
126 }
127 } } }