1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * The unsigned part of a [`channel_announcement`] message.
14 * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
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 {
22 if (ptr != 0) { bindings.UnsignedChannelAnnouncement_free(ptr); }
26 * The advertised channel features
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); };
38 * The advertised channel features
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); };
48 * The genesis hash of the blockchain where the channel is to be opened
50 public byte[] get_chain_hash() {
51 byte[] ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this.ptr);
52 Reference.reachabilityFence(this);
57 * The genesis hash of the blockchain where the channel is to be opened
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);
66 * The short channel ID
68 public long get_short_channel_id() {
69 long ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this.ptr);
70 Reference.reachabilityFence(this);
75 * The short channel ID
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);
84 * One of the two `node_id`s which are endpoints of this channel
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); };
96 * One of the two `node_id`s which are endpoints of this channel
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); };
106 * The other of the two `node_id`s which are endpoints of this channel
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); };
118 * The other of the two `node_id`s which are endpoints of this channel
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); };
128 * The funding key for the first node
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); };
140 * The funding key for the first node
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); };
150 * The funding key for the second node
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); };
162 * The funding key for the second node
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); };
172 * Excess data which was signed as a part of the message which we do not (yet) understand how
175 * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
177 * Returns a copy of the field.
179 public byte[] get_excess_data() {
180 byte[] ret = bindings.UnsignedChannelAnnouncement_get_excess_data(this.ptr);
181 Reference.reachabilityFence(this);
186 * Excess data which was signed as a part of the message which we do not (yet) understand how
189 * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
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);
198 * Constructs a new UnsignedChannelAnnouncement given each field
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); };
222 long ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
223 Reference.reachabilityFence(this);
228 * Creates a copy of the UnsignedChannelAnnouncement
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); };
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.
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); };
252 @Override public boolean equals(Object o) {
253 if (!(o instanceof UnsignedChannelAnnouncement)) return false;
254 return this.eq((UnsignedChannelAnnouncement)o);
257 * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
259 public byte[] write() {
260 byte[] ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
261 Reference.reachabilityFence(this);
266 * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
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);