Update auto-generated bindings to latest upstream
[ldk-java] / src / main / java / org / ldk / structs / ChannelInfo.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 javax.annotation.Nullable;
8
9
10 /**
11  * Details about a channel (both directions).
12  * Received within a channel announcement.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelInfo extends CommonBase {
16         ChannelInfo(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelInfo_free(ptr); }
21         }
22
23         /**
24          * Protocol features of a channel communicated during its announcement
25          */
26         public ChannelFeatures get_features() {
27                 long ret = bindings.ChannelInfo_get_features(this.ptr);
28                 if (ret < 1024) { return null; }
29                 ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
30                 ret_hu_conv.ptrs_to.add(this);
31                 return ret_hu_conv;
32         }
33
34         /**
35          * Protocol features of a channel communicated during its announcement
36          */
37         public void set_features(ChannelFeatures val) {
38                 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
39                 this.ptrs_to.add(val);
40         }
41
42         /**
43          * Source node of the first direction of a channel
44          */
45         public byte[] get_node_one() {
46                 byte[] ret = bindings.ChannelInfo_get_node_one(this.ptr);
47                 return ret;
48         }
49
50         /**
51          * Source node of the first direction of a channel
52          */
53         public void set_node_one(byte[] val) {
54                 bindings.ChannelInfo_set_node_one(this.ptr, val);
55         }
56
57         /**
58          * Details about the first direction of a channel
59          * 
60          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
61          */
62         @Nullable
63         public DirectionalChannelInfo get_one_to_two() {
64                 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
65                 if (ret < 1024) { return null; }
66                 DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
67                 ret_hu_conv.ptrs_to.add(this);
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Details about the first direction of a channel
73          * 
74          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
75          */
76         public void set_one_to_two(@Nullable DirectionalChannelInfo val) {
77                 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1);
78                 this.ptrs_to.add(val);
79         }
80
81         /**
82          * Source node of the second direction of a channel
83          */
84         public byte[] get_node_two() {
85                 byte[] ret = bindings.ChannelInfo_get_node_two(this.ptr);
86                 return ret;
87         }
88
89         /**
90          * Source node of the second direction of a channel
91          */
92         public void set_node_two(byte[] val) {
93                 bindings.ChannelInfo_set_node_two(this.ptr, val);
94         }
95
96         /**
97          * Details about the second direction of a channel
98          * 
99          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
100          */
101         @Nullable
102         public DirectionalChannelInfo get_two_to_one() {
103                 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
104                 if (ret < 1024) { return null; }
105                 DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
106                 ret_hu_conv.ptrs_to.add(this);
107                 return ret_hu_conv;
108         }
109
110         /**
111          * Details about the second direction of a channel
112          * 
113          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
114          */
115         public void set_two_to_one(@Nullable DirectionalChannelInfo val) {
116                 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1);
117                 this.ptrs_to.add(val);
118         }
119
120         /**
121          * The channel capacity as seen on-chain, if chain lookup is available.
122          */
123         public Option_u64Z get_capacity_sats() {
124                 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
125                 if (ret < 1024) { return null; }
126                 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
127                 ret_hu_conv.ptrs_to.add(this);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * The channel capacity as seen on-chain, if chain lookup is available.
133          */
134         public void set_capacity_sats(Option_u64Z val) {
135                 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
136         }
137
138         /**
139          * An initial announcement of the channel
140          * Mostly redundant with the data we store in fields explicitly.
141          * Everything else is useful only for sending out for initial routing sync.
142          * Not stored if contains excess data to prevent DoS.
143          * 
144          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
145          */
146         @Nullable
147         public ChannelAnnouncement get_announcement_message() {
148                 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
149                 if (ret < 1024) { return null; }
150                 ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
151                 ret_hu_conv.ptrs_to.add(this);
152                 return ret_hu_conv;
153         }
154
155         /**
156          * An initial announcement of the channel
157          * Mostly redundant with the data we store in fields explicitly.
158          * Everything else is useful only for sending out for initial routing sync.
159          * Not stored if contains excess data to prevent DoS.
160          * 
161          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
162          */
163         public void set_announcement_message(@Nullable ChannelAnnouncement val) {
164                 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
165                 this.ptrs_to.add(val);
166         }
167
168         /**
169          * Constructs a new ChannelInfo given each field
170          */
171         public static ChannelInfo of(ChannelFeatures features_arg, byte[] node_one_arg, DirectionalChannelInfo one_to_two_arg, byte[] node_two_arg, DirectionalChannelInfo two_to_one_arg, Option_u64Z capacity_sats_arg, ChannelAnnouncement announcement_message_arg) {
172                 long ret = bindings.ChannelInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, node_one_arg, one_to_two_arg == null ? 0 : one_to_two_arg.ptr & ~1, node_two_arg, two_to_one_arg == null ? 0 : two_to_one_arg.ptr & ~1, capacity_sats_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
173                 if (ret < 1024) { return null; }
174                 ChannelInfo ret_hu_conv = new ChannelInfo(null, ret);
175                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
176                 ret_hu_conv.ptrs_to.add(features_arg);
177                 ret_hu_conv.ptrs_to.add(one_to_two_arg);
178                 ret_hu_conv.ptrs_to.add(two_to_one_arg);
179                 ret_hu_conv.ptrs_to.add(announcement_message_arg);
180                 return ret_hu_conv;
181         }
182
183         /**
184          * Creates a copy of the ChannelInfo
185          */
186         public ChannelInfo clone() {
187                 long ret = bindings.ChannelInfo_clone(this.ptr);
188                 if (ret < 1024) { return null; }
189                 ChannelInfo ret_hu_conv = new ChannelInfo(null, ret);
190                 ret_hu_conv.ptrs_to.add(this);
191                 return ret_hu_conv;
192         }
193
194         /**
195          * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
196          */
197         public byte[] write() {
198                 byte[] ret = bindings.ChannelInfo_write(this.ptr);
199                 return ret;
200         }
201
202         /**
203          * Read a ChannelInfo from a byte array, created by ChannelInfo_write
204          */
205         public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
206                 long ret = bindings.ChannelInfo_read(ser);
207                 if (ret < 1024) { return null; }
208                 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
209                 return ret_hu_conv;
210         }
211
212 }