[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Init.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 /**
10  * An [`init`] message to be sent to or received from a peer.
11  * 
12  * [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
13  */
14 public class Init : CommonBase {
15         internal Init(object _dummy, long ptr) : base(ptr) { }
16         ~Init() {
17                 if (ptr != 0) { bindings.Init_free(ptr); }
18         }
19
20         /**
21          * The relevant features which the sender supports.
22          */
23         public InitFeatures get_features() {
24                 long ret = bindings.Init_get_features(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The relevant features which the sender supports.
34          */
35         public void set_features(org.ldk.structs.InitFeatures val) {
36                 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * Indicates chains the sender is interested in.
44          * 
45          * If there are no common chains, the connection will be closed.
46          * 
47          * Returns a copy of the field.
48          */
49         public Option_CVec_ThirtyTwoBytesZZ get_networks() {
50                 long ret = bindings.Init_get_networks(this.ptr);
51                 GC.KeepAlive(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
54                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Indicates chains the sender is interested in.
60          * 
61          * If there are no common chains, the connection will be closed.
62          */
63         public void set_networks(org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ val) {
64                 bindings.Init_set_networks(this.ptr, val.ptr);
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(val);
67                 if (this != null) { this.ptrs_to.AddLast(val); };
68         }
69
70         /**
71          * The receipient's network address.
72          * 
73          * This adds the option to report a remote IP address back to a connecting peer using the init
74          * message. A node can decide to use that information to discover a potential update to its
75          * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
76          * the new address.
77          */
78         public Option_SocketAddressZ get_remote_network_address() {
79                 long ret = bindings.Init_get_remote_network_address(this.ptr);
80                 GC.KeepAlive(this);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.Option_SocketAddressZ ret_hu_conv = org.ldk.structs.Option_SocketAddressZ.constr_from_ptr(ret);
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
84                 return ret_hu_conv;
85         }
86
87         /**
88          * The receipient's network address.
89          * 
90          * This adds the option to report a remote IP address back to a connecting peer using the init
91          * message. A node can decide to use that information to discover a potential update to its
92          * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
93          * the new address.
94          */
95         public void set_remote_network_address(org.ldk.structs.Option_SocketAddressZ val) {
96                 bindings.Init_set_remote_network_address(this.ptr, val.ptr);
97                 GC.KeepAlive(this);
98                 GC.KeepAlive(val);
99                 if (this != null) { this.ptrs_to.AddLast(val); };
100         }
101
102         /**
103          * Constructs a new Init given each field
104          */
105         public static Init of(org.ldk.structs.InitFeatures features_arg, org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ networks_arg, org.ldk.structs.Option_SocketAddressZ remote_network_address_arg) {
106                 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr, networks_arg.ptr, remote_network_address_arg.ptr);
107                 GC.KeepAlive(features_arg);
108                 GC.KeepAlive(networks_arg);
109                 GC.KeepAlive(remote_network_address_arg);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(networks_arg); };
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(remote_network_address_arg); };
116                 return ret_hu_conv;
117         }
118
119         internal long clone_ptr() {
120                 long ret = bindings.Init_clone_ptr(this.ptr);
121                 GC.KeepAlive(this);
122                 return ret;
123         }
124
125         /**
126          * Creates a copy of the Init
127          */
128         public Init clone() {
129                 long ret = bindings.Init_clone(this.ptr);
130                 GC.KeepAlive(this);
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
133                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
134                 return ret_hu_conv;
135         }
136
137         /**
138          * Generates a non-cryptographic 64-bit hash of the Init.
139          */
140         public long hash() {
141                 long ret = bindings.Init_hash(this.ptr);
142                 GC.KeepAlive(this);
143                 return ret;
144         }
145
146         public override int GetHashCode() {
147                 return (int)this.hash();
148         }
149         /**
150          * Checks if two Inits contain equal inner contents.
151          * This ignores pointers and is_owned flags and looks at the values in fields.
152          * Two objects with NULL inner values will be considered "equal" here.
153          */
154         public bool eq(org.ldk.structs.Init b) {
155                 bool ret = bindings.Init_eq(this.ptr, b == null ? 0 : b.ptr);
156                 GC.KeepAlive(this);
157                 GC.KeepAlive(b);
158                 if (this != null) { this.ptrs_to.AddLast(b); };
159                 return ret;
160         }
161
162         public override bool Equals(object o) {
163                 if (!(o is Init)) return false;
164                 return this.eq((Init)o);
165         }
166         /**
167          * Serialize the Init object into a byte array which can be read by Init_read
168          */
169         public byte[] write() {
170                 long ret = bindings.Init_write(this.ptr);
171                 GC.KeepAlive(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
174                 return ret_conv;
175         }
176
177         /**
178          * Read a Init from a byte array, created by Init_write
179          */
180         public static Result_InitDecodeErrorZ read(byte[] ser) {
181                 long ret = bindings.Init_read(InternalUtils.encodeUint8Array(ser));
182                 GC.KeepAlive(ser);
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
185                 return ret_hu_conv;
186         }
187
188 }
189 } } }