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 long ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
173 Reference.reachabilityFence(this);
178 * Creates a copy of the UnsignedChannelAnnouncement
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); };
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.
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); };
202 @Override public boolean equals(Object o) {
203 if (!(o instanceof UnsignedChannelAnnouncement)) return false;
204 return this.eq((UnsignedChannelAnnouncement)o);
207 * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
209 public byte[] write() {
210 byte[] ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
211 Reference.reachabilityFence(this);
216 * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
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);