d93703ca19a7971fa9e5873fad60d134c211c42e
[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         long clone_ptr() {
172                 long ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
173                 Reference.reachabilityFence(this);
174                 return ret;
175         }
176
177         /**
178          * Creates a copy of the UnsignedChannelAnnouncement
179          */
180         public UnsignedChannelAnnouncement clone() {
181                 long ret = bindings.UnsignedChannelAnnouncement_clone(this.ptr);
182                 Reference.reachabilityFence(this);
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
186                 return ret_hu_conv;
187         }
188
189         /**
190          * Checks if two UnsignedChannelAnnouncements contain equal inner contents.
191          * This ignores pointers and is_owned flags and looks at the values in fields.
192          * Two objects with NULL inner values will be considered "equal" here.
193          */
194         public boolean eq(org.ldk.structs.UnsignedChannelAnnouncement b) {
195                 boolean ret = bindings.UnsignedChannelAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
196                 Reference.reachabilityFence(this);
197                 Reference.reachabilityFence(b);
198                 if (this != null) { this.ptrs_to.add(b); };
199                 return ret;
200         }
201
202         @Override public boolean equals(Object o) {
203                 if (!(o instanceof UnsignedChannelAnnouncement)) return false;
204                 return this.eq((UnsignedChannelAnnouncement)o);
205         }
206         /**
207          * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
208          */
209         public byte[] write() {
210                 byte[] ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
211                 Reference.reachabilityFence(this);
212                 return ret;
213         }
214
215         /**
216          * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
217          */
218         public static Result_UnsignedChannelAnnouncementDecodeErrorZ read(byte[] ser) {
219                 long ret = bindings.UnsignedChannelAnnouncement_read(ser);
220                 Reference.reachabilityFence(ser);
221                 if (ret >= 0 && ret <= 4096) { return null; }
222                 Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
223                 return ret_hu_conv;
224         }
225
226 }