[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / UnsignedChannelAnnouncement.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  * The unsigned part of a [`channel_announcement`] message.
13  * 
14  * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UnsignedChannelAnnouncement extends CommonBase {
18         UnsignedChannelAnnouncement(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UnsignedChannelAnnouncement_free(ptr); }
23         }
24
25         /**
26          * The advertised channel features
27          */
28         public ChannelFeatures get_features() {
29                 long ret = bindings.UnsignedChannelAnnouncement_get_features(this.ptr);
30                 Reference.reachabilityFence(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(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 advertised channel features
39          */
40         public void set_features(org.ldk.structs.ChannelFeatures val) {
41                 bindings.UnsignedChannelAnnouncement_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          * The genesis hash of the blockchain where the channel is to be opened
49          */
50         public byte[] get_chain_hash() {
51                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * The genesis hash of the blockchain where the channel is to be opened
58          */
59         public void set_chain_hash(byte[] val) {
60                 bindings.UnsignedChannelAnnouncement_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * The short channel ID
67          */
68         public long get_short_channel_id() {
69                 long ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * The short channel ID
76          */
77         public void set_short_channel_id(long val) {
78                 bindings.UnsignedChannelAnnouncement_set_short_channel_id(this.ptr, val);
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(val);
81         }
82
83         /**
84          * One of the two `node_id`s which are endpoints of this channel
85          */
86         public NodeId get_node_id_1() {
87                 long ret = bindings.UnsignedChannelAnnouncement_get_node_id_1(this.ptr);
88                 Reference.reachabilityFence(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * One of the two `node_id`s which are endpoints of this channel
97          */
98         public void set_node_id_1(org.ldk.structs.NodeId val) {
99                 bindings.UnsignedChannelAnnouncement_set_node_id_1(this.ptr, val == null ? 0 : val.ptr);
100                 Reference.reachabilityFence(this);
101                 Reference.reachabilityFence(val);
102                 if (this != null) { this.ptrs_to.add(val); };
103         }
104
105         /**
106          * The other of the two `node_id`s which are endpoints of this channel
107          */
108         public NodeId get_node_id_2() {
109                 long ret = bindings.UnsignedChannelAnnouncement_get_node_id_2(this.ptr);
110                 Reference.reachabilityFence(this);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
114                 return ret_hu_conv;
115         }
116
117         /**
118          * The other of the two `node_id`s which are endpoints of this channel
119          */
120         public void set_node_id_2(org.ldk.structs.NodeId val) {
121                 bindings.UnsignedChannelAnnouncement_set_node_id_2(this.ptr, val == null ? 0 : val.ptr);
122                 Reference.reachabilityFence(this);
123                 Reference.reachabilityFence(val);
124                 if (this != null) { this.ptrs_to.add(val); };
125         }
126
127         /**
128          * The funding key for the first node
129          */
130         public NodeId get_bitcoin_key_1() {
131                 long ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_1(this.ptr);
132                 Reference.reachabilityFence(this);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
136                 return ret_hu_conv;
137         }
138
139         /**
140          * The funding key for the first node
141          */
142         public void set_bitcoin_key_1(org.ldk.structs.NodeId val) {
143                 bindings.UnsignedChannelAnnouncement_set_bitcoin_key_1(this.ptr, val == null ? 0 : val.ptr);
144                 Reference.reachabilityFence(this);
145                 Reference.reachabilityFence(val);
146                 if (this != null) { this.ptrs_to.add(val); };
147         }
148
149         /**
150          * The funding key for the second node
151          */
152         public NodeId get_bitcoin_key_2() {
153                 long ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_2(this.ptr);
154                 Reference.reachabilityFence(this);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
158                 return ret_hu_conv;
159         }
160
161         /**
162          * The funding key for the second node
163          */
164         public void set_bitcoin_key_2(org.ldk.structs.NodeId val) {
165                 bindings.UnsignedChannelAnnouncement_set_bitcoin_key_2(this.ptr, val == null ? 0 : val.ptr);
166                 Reference.reachabilityFence(this);
167                 Reference.reachabilityFence(val);
168                 if (this != null) { this.ptrs_to.add(val); };
169         }
170
171         /**
172          * Excess data which was signed as a part of the message which we do not (yet) understand how
173          * to decode.
174          * 
175          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
176          * 
177          * Returns a copy of the field.
178          */
179         public byte[] get_excess_data() {
180                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_excess_data(this.ptr);
181                 Reference.reachabilityFence(this);
182                 return ret;
183         }
184
185         /**
186          * Excess data which was signed as a part of the message which we do not (yet) understand how
187          * to decode.
188          * 
189          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
190          */
191         public void set_excess_data(byte[] val) {
192                 bindings.UnsignedChannelAnnouncement_set_excess_data(this.ptr, val);
193                 Reference.reachabilityFence(this);
194                 Reference.reachabilityFence(val);
195         }
196
197         /**
198          * Constructs a new UnsignedChannelAnnouncement given each field
199          */
200         public static UnsignedChannelAnnouncement of(org.ldk.structs.ChannelFeatures features_arg, byte[] chain_hash_arg, long short_channel_id_arg, org.ldk.structs.NodeId node_id_1_arg, org.ldk.structs.NodeId node_id_2_arg, org.ldk.structs.NodeId bitcoin_key_1_arg, org.ldk.structs.NodeId bitcoin_key_2_arg, byte[] excess_data_arg) {
201                 long ret = bindings.UnsignedChannelAnnouncement_new(features_arg == null ? 0 : features_arg.ptr, InternalUtils.check_arr_len(chain_hash_arg, 32), short_channel_id_arg, node_id_1_arg == null ? 0 : node_id_1_arg.ptr, node_id_2_arg == null ? 0 : node_id_2_arg.ptr, bitcoin_key_1_arg == null ? 0 : bitcoin_key_1_arg.ptr, bitcoin_key_2_arg == null ? 0 : bitcoin_key_2_arg.ptr, excess_data_arg);
202                 Reference.reachabilityFence(features_arg);
203                 Reference.reachabilityFence(chain_hash_arg);
204                 Reference.reachabilityFence(short_channel_id_arg);
205                 Reference.reachabilityFence(node_id_1_arg);
206                 Reference.reachabilityFence(node_id_2_arg);
207                 Reference.reachabilityFence(bitcoin_key_1_arg);
208                 Reference.reachabilityFence(bitcoin_key_2_arg);
209                 Reference.reachabilityFence(excess_data_arg);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
213                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features_arg); };
214                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_id_1_arg); };
215                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_id_2_arg); };
216                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(bitcoin_key_1_arg); };
217                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(bitcoin_key_2_arg); };
218                 return ret_hu_conv;
219         }
220
221         long clone_ptr() {
222                 long ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
223                 Reference.reachabilityFence(this);
224                 return ret;
225         }
226
227         /**
228          * Creates a copy of the UnsignedChannelAnnouncement
229          */
230         public UnsignedChannelAnnouncement clone() {
231                 long ret = bindings.UnsignedChannelAnnouncement_clone(this.ptr);
232                 Reference.reachabilityFence(this);
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
236                 return ret_hu_conv;
237         }
238
239         /**
240          * Checks if two UnsignedChannelAnnouncements contain equal inner contents.
241          * This ignores pointers and is_owned flags and looks at the values in fields.
242          * Two objects with NULL inner values will be considered "equal" here.
243          */
244         public boolean eq(org.ldk.structs.UnsignedChannelAnnouncement b) {
245                 boolean ret = bindings.UnsignedChannelAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
246                 Reference.reachabilityFence(this);
247                 Reference.reachabilityFence(b);
248                 if (this != null) { this.ptrs_to.add(b); };
249                 return ret;
250         }
251
252         @Override public boolean equals(Object o) {
253                 if (!(o instanceof UnsignedChannelAnnouncement)) return false;
254                 return this.eq((UnsignedChannelAnnouncement)o);
255         }
256         /**
257          * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
258          */
259         public byte[] write() {
260                 byte[] ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
261                 Reference.reachabilityFence(this);
262                 return ret;
263         }
264
265         /**
266          * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
267          */
268         public static Result_UnsignedChannelAnnouncementDecodeErrorZ read(byte[] ser) {
269                 long ret = bindings.UnsignedChannelAnnouncement_read(ser);
270                 Reference.reachabilityFence(ser);
271                 if (ret >= 0 && ret <= 4096) { return null; }
272                 Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
273                 return ret_hu_conv;
274         }
275
276 }