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