d4d1fe3862776e6736ec5ae4f599bcc5d8529aca
[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 or received from a peer
11  */
12 public class Init : CommonBase {
13         internal Init(object _dummy, long ptr) : base(ptr) { }
14         ~Init() {
15                 if (ptr != 0) { bindings.Init_free(ptr); }
16         }
17
18         /**
19          * The relevant features which the sender supports
20          */
21         public InitFeatures get_features() {
22                 long ret = bindings.Init_get_features(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * The relevant features which the sender supports
32          */
33         public void set_features(org.ldk.structs.InitFeatures val) {
34                 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * The receipient's network address. This adds the option to report a remote IP address
42          * back to a connecting peer using the init message. A node can decide to use that information
43          * to discover a potential update to its public IPv4 address (NAT) and use
44          * that for a node_announcement update message containing the new address.
45          */
46         public Option_NetAddressZ get_remote_network_address() {
47                 long ret = bindings.Init_get_remote_network_address(this.ptr);
48                 GC.KeepAlive(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.Option_NetAddressZ ret_hu_conv = org.ldk.structs.Option_NetAddressZ.constr_from_ptr(ret);
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The receipient's network address. This adds the option to report a remote IP address
57          * back to a connecting peer using the init message. A node can decide to use that information
58          * to discover a potential update to its public IPv4 address (NAT) and use
59          * that for a node_announcement update message containing the new address.
60          */
61         public void set_remote_network_address(org.ldk.structs.Option_NetAddressZ val) {
62                 bindings.Init_set_remote_network_address(this.ptr, val.ptr);
63                 GC.KeepAlive(this);
64                 GC.KeepAlive(val);
65         }
66
67         /**
68          * Constructs a new Init given each field
69          */
70         public static Init of(org.ldk.structs.InitFeatures features_arg, org.ldk.structs.Option_NetAddressZ remote_network_address_arg) {
71                 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr, remote_network_address_arg.ptr);
72                 GC.KeepAlive(features_arg);
73                 GC.KeepAlive(remote_network_address_arg);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
78                 return ret_hu_conv;
79         }
80
81         internal long clone_ptr() {
82                 long ret = bindings.Init_clone_ptr(this.ptr);
83                 GC.KeepAlive(this);
84                 return ret;
85         }
86
87         /**
88          * Creates a copy of the Init
89          */
90         public Init clone() {
91                 long ret = bindings.Init_clone(this.ptr);
92                 GC.KeepAlive(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Checks if two Inits contain equal inner contents.
101          * This ignores pointers and is_owned flags and looks at the values in fields.
102          * Two objects with NULL inner values will be considered "equal" here.
103          */
104         public bool eq(org.ldk.structs.Init b) {
105                 bool ret = bindings.Init_eq(this.ptr, b == null ? 0 : b.ptr);
106                 GC.KeepAlive(this);
107                 GC.KeepAlive(b);
108                 if (this != null) { this.ptrs_to.AddLast(b); };
109                 return ret;
110         }
111
112         public override bool Equals(object o) {
113                 if (!(o is Init)) return false;
114                 return this.eq((Init)o);
115         }
116         /**
117          * Serialize the Init object into a byte array which can be read by Init_read
118          */
119         public byte[] write() {
120                 byte[] ret = bindings.Init_write(this.ptr);
121                 GC.KeepAlive(this);
122                 return ret;
123         }
124
125         /**
126          * Read a Init from a byte array, created by Init_write
127          */
128         public static Result_InitDecodeErrorZ read(byte[] ser) {
129                 long ret = bindings.Init_read(ser);
130                 GC.KeepAlive(ser);
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
133                 return ret_hu_conv;
134         }
135
136 }
137 } } }