d042e41b80565c763d7caf0a566417c2c69f8119
[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
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class UnsignedChannelAnnouncement extends CommonBase {
16         UnsignedChannelAnnouncement(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.UnsignedChannelAnnouncement_free(ptr); }
21         }
22
23         /**
24          * The advertised channel features
25          */
26         public ChannelFeatures get_features() {
27                 long ret = bindings.UnsignedChannelAnnouncement_get_features(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The advertised channel features
37          */
38         public void set_features(ChannelFeatures val) {
39                 bindings.UnsignedChannelAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42                 if (this != null) { this.ptrs_to.add(val); };
43         }
44
45         /**
46          * The genesis hash of the blockchain where the channel is to be opened
47          */
48         public byte[] get_chain_hash() {
49                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * The genesis hash of the blockchain where the channel is to be opened
56          */
57         public void set_chain_hash(byte[] val) {
58                 bindings.UnsignedChannelAnnouncement_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * The short channel ID
65          */
66         public long get_short_channel_id() {
67                 long ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
73          * The short channel ID
74          */
75         public void set_short_channel_id(long val) {
76                 bindings.UnsignedChannelAnnouncement_set_short_channel_id(this.ptr, val);
77                 Reference.reachabilityFence(this);
78                 Reference.reachabilityFence(val);
79         }
80
81         /**
82          * One of the two node_ids which are endpoints of this channel
83          */
84         public byte[] get_node_id_1() {
85                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_node_id_1(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * One of the two node_ids which are endpoints of this channel
92          */
93         public void set_node_id_1(byte[] val) {
94                 bindings.UnsignedChannelAnnouncement_set_node_id_1(this.ptr, InternalUtils.check_arr_len(val, 33));
95                 Reference.reachabilityFence(this);
96                 Reference.reachabilityFence(val);
97         }
98
99         /**
100          * The other of the two node_ids which are endpoints of this channel
101          */
102         public byte[] get_node_id_2() {
103                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_node_id_2(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         /**
109          * The other of the two node_ids which are endpoints of this channel
110          */
111         public void set_node_id_2(byte[] val) {
112                 bindings.UnsignedChannelAnnouncement_set_node_id_2(this.ptr, InternalUtils.check_arr_len(val, 33));
113                 Reference.reachabilityFence(this);
114                 Reference.reachabilityFence(val);
115         }
116
117         /**
118          * The funding key for the first node
119          */
120         public byte[] get_bitcoin_key_1() {
121                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_1(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         /**
127          * The funding key for the first node
128          */
129         public void set_bitcoin_key_1(byte[] val) {
130                 bindings.UnsignedChannelAnnouncement_set_bitcoin_key_1(this.ptr, InternalUtils.check_arr_len(val, 33));
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(val);
133         }
134
135         /**
136          * The funding key for the second node
137          */
138         public byte[] get_bitcoin_key_2() {
139                 byte[] ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_2(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * The funding key for the second node
146          */
147         public void set_bitcoin_key_2(byte[] val) {
148                 bindings.UnsignedChannelAnnouncement_set_bitcoin_key_2(this.ptr, InternalUtils.check_arr_len(val, 33));
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(val);
151         }
152
153         long clone_ptr() {
154                 long ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
155                 Reference.reachabilityFence(this);
156                 return ret;
157         }
158
159         /**
160          * Creates a copy of the UnsignedChannelAnnouncement
161          */
162         public UnsignedChannelAnnouncement clone() {
163                 long ret = bindings.UnsignedChannelAnnouncement_clone(this.ptr);
164                 Reference.reachabilityFence(this);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
168                 return ret_hu_conv;
169         }
170
171         /**
172          * Checks if two UnsignedChannelAnnouncements contain equal inner contents.
173          * This ignores pointers and is_owned flags and looks at the values in fields.
174          * Two objects with NULL inner values will be considered "equal" here.
175          */
176         public boolean eq(UnsignedChannelAnnouncement b) {
177                 boolean ret = bindings.UnsignedChannelAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
178                 Reference.reachabilityFence(this);
179                 Reference.reachabilityFence(b);
180                 if (this != null) { this.ptrs_to.add(b); };
181                 return ret;
182         }
183
184         @Override public boolean equals(Object o) {
185                 if (!(o instanceof UnsignedChannelAnnouncement)) return false;
186                 return this.eq((UnsignedChannelAnnouncement)o);
187         }
188         /**
189          * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
190          */
191         public byte[] write() {
192                 byte[] ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
193                 Reference.reachabilityFence(this);
194                 return ret;
195         }
196
197         /**
198          * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
199          */
200         public static Result_UnsignedChannelAnnouncementDecodeErrorZ read(byte[] ser) {
201                 long ret = bindings.UnsignedChannelAnnouncement_read(ser);
202                 Reference.reachabilityFence(ser);
203                 if (ret >= 0 && ret <= 4096) { return null; }
204                 Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
205                 return ret_hu_conv;
206         }
207
208 }