Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / ChannelDetails.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 of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ChannelDetails extends CommonBase {
15         ChannelDetails(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ChannelDetails_free(ptr); }
20         }
21
22         /**
23          * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
24          * thereafter this is the txid of the funding transaction xor the funding transaction output).
25          * Note that this means this value is *not* persistent - it can change once during the
26          * lifetime of the channel.
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.ChannelDetails_get_channel_id(this.ptr);
30                 return ret;
31         }
32
33         /**
34          * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
35          * thereafter this is the txid of the funding transaction xor the funding transaction output).
36          * Note that this means this value is *not* persistent - it can change once during the
37          * lifetime of the channel.
38          */
39         public void set_channel_id(byte[] val) {
40                 bindings.ChannelDetails_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
41         }
42
43         /**
44          * Parameters which apply to our counterparty. See individual fields for more information.
45          */
46         public ChannelCounterparty get_counterparty() {
47                 long ret = bindings.ChannelDetails_get_counterparty(this.ptr);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
50                 ret_hu_conv.ptrs_to.add(this);
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Parameters which apply to our counterparty. See individual fields for more information.
56          */
57         public void set_counterparty(ChannelCounterparty val) {
58                 bindings.ChannelDetails_set_counterparty(this.ptr, val == null ? 0 : val.ptr & ~1);
59         }
60
61         /**
62          * The Channel's funding transaction output, if we've negotiated the funding transaction with
63          * our counterparty already.
64          * 
65          * Note that, if this has been set, `channel_id` will be equivalent to
66          * `funding_txo.unwrap().to_channel_id()`.
67          * 
68          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
69          */
70         @Nullable
71         public OutPoint get_funding_txo() {
72                 long ret = bindings.ChannelDetails_get_funding_txo(this.ptr);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
75                 ret_hu_conv.ptrs_to.add(this);
76                 return ret_hu_conv;
77         }
78
79         /**
80          * The Channel's funding transaction output, if we've negotiated the funding transaction with
81          * our counterparty already.
82          * 
83          * Note that, if this has been set, `channel_id` will be equivalent to
84          * `funding_txo.unwrap().to_channel_id()`.
85          * 
86          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
87          */
88         public void set_funding_txo(@Nullable OutPoint val) {
89                 bindings.ChannelDetails_set_funding_txo(this.ptr, val == null ? 0 : val.ptr & ~1);
90         }
91
92         /**
93          * The position of the funding transaction in the chain. None if the funding transaction has
94          * not yet been confirmed and the channel fully opened.
95          */
96         public Option_u64Z get_short_channel_id() {
97                 long ret = bindings.ChannelDetails_get_short_channel_id(this.ptr);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
100                 ret_hu_conv.ptrs_to.add(this);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * The position of the funding transaction in the chain. None if the funding transaction has
106          * not yet been confirmed and the channel fully opened.
107          */
108         public void set_short_channel_id(Option_u64Z val) {
109                 bindings.ChannelDetails_set_short_channel_id(this.ptr, val.ptr);
110         }
111
112         /**
113          * The value, in satoshis, of this channel as appears in the funding output
114          */
115         public long get_channel_value_satoshis() {
116                 long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr);
117                 return ret;
118         }
119
120         /**
121          * The value, in satoshis, of this channel as appears in the funding output
122          */
123         public void set_channel_value_satoshis(long val) {
124                 bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val);
125         }
126
127         /**
128          * The value, in satoshis, that must always be held in the channel for us. This value ensures
129          * that if we broadcast a revoked state, our counterparty can punish us by claiming at least
130          * this value on chain.
131          * 
132          * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
133          * 
134          * This value will be `None` for outbound channels until the counterparty accepts the channel.
135          * 
136          * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
137          */
138         public Option_u64Z get_unspendable_punishment_reserve() {
139                 long ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
142                 ret_hu_conv.ptrs_to.add(this);
143                 return ret_hu_conv;
144         }
145
146         /**
147          * The value, in satoshis, that must always be held in the channel for us. This value ensures
148          * that if we broadcast a revoked state, our counterparty can punish us by claiming at least
149          * this value on chain.
150          * 
151          * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
152          * 
153          * This value will be `None` for outbound channels until the counterparty accepts the channel.
154          * 
155          * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
156          */
157         public void set_unspendable_punishment_reserve(Option_u64Z val) {
158                 bindings.ChannelDetails_set_unspendable_punishment_reserve(this.ptr, val.ptr);
159         }
160
161         /**
162          * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound.
163          */
164         public long get_user_channel_id() {
165                 long ret = bindings.ChannelDetails_get_user_channel_id(this.ptr);
166                 return ret;
167         }
168
169         /**
170          * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound.
171          */
172         public void set_user_channel_id(long val) {
173                 bindings.ChannelDetails_set_user_channel_id(this.ptr, val);
174         }
175
176         /**
177          * The available outbound capacity for sending HTLCs to the remote peer. This does not include
178          * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
179          * available for inclusion in new outbound HTLCs). This further does not include any pending
180          * outgoing HTLCs which are awaiting some other resolution to be sent.
181          * 
182          * This value is not exact. Due to various in-flight changes, feerate changes, and our
183          * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
184          * should be able to spend nearly this amount.
185          */
186         public long get_outbound_capacity_msat() {
187                 long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this.ptr);
188                 return ret;
189         }
190
191         /**
192          * The available outbound capacity for sending HTLCs to the remote peer. This does not include
193          * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
194          * available for inclusion in new outbound HTLCs). This further does not include any pending
195          * outgoing HTLCs which are awaiting some other resolution to be sent.
196          * 
197          * This value is not exact. Due to various in-flight changes, feerate changes, and our
198          * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
199          * should be able to spend nearly this amount.
200          */
201         public void set_outbound_capacity_msat(long val) {
202                 bindings.ChannelDetails_set_outbound_capacity_msat(this.ptr, val);
203         }
204
205         /**
206          * The available inbound capacity for the remote peer to send HTLCs to us. This does not
207          * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
208          * available for inclusion in new inbound HTLCs).
209          * Note that there are some corner cases not fully handled here, so the actual available
210          * inbound capacity may be slightly higher than this.
211          * 
212          * This value is not exact. Due to various in-flight changes, feerate changes, and our
213          * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
214          * However, our counterparty should be able to spend nearly this amount.
215          */
216         public long get_inbound_capacity_msat() {
217                 long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this.ptr);
218                 return ret;
219         }
220
221         /**
222          * The available inbound capacity for the remote peer to send HTLCs to us. This does not
223          * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
224          * available for inclusion in new inbound HTLCs).
225          * Note that there are some corner cases not fully handled here, so the actual available
226          * inbound capacity may be slightly higher than this.
227          * 
228          * This value is not exact. Due to various in-flight changes, feerate changes, and our
229          * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
230          * However, our counterparty should be able to spend nearly this amount.
231          */
232         public void set_inbound_capacity_msat(long val) {
233                 bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val);
234         }
235
236         /**
237          * The number of required confirmations on the funding transaction before the funding will be
238          * considered \"locked\". This number is selected by the channel fundee (i.e. us if
239          * [`is_outbound`] is *not* set), and can be selected for inbound channels with
240          * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
241          * [`ChannelHandshakeLimits::max_minimum_depth`].
242          * 
243          * This value will be `None` for outbound channels until the counterparty accepts the channel.
244          * 
245          * [`is_outbound`]: ChannelDetails::is_outbound
246          * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
247          * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
248          */
249         public Option_u32Z get_confirmations_required() {
250                 long ret = bindings.ChannelDetails_get_confirmations_required(this.ptr);
251                 if (ret >= 0 && ret <= 4096) { return null; }
252                 Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
253                 ret_hu_conv.ptrs_to.add(this);
254                 return ret_hu_conv;
255         }
256
257         /**
258          * The number of required confirmations on the funding transaction before the funding will be
259          * considered \"locked\". This number is selected by the channel fundee (i.e. us if
260          * [`is_outbound`] is *not* set), and can be selected for inbound channels with
261          * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
262          * [`ChannelHandshakeLimits::max_minimum_depth`].
263          * 
264          * This value will be `None` for outbound channels until the counterparty accepts the channel.
265          * 
266          * [`is_outbound`]: ChannelDetails::is_outbound
267          * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
268          * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
269          */
270         public void set_confirmations_required(Option_u32Z val) {
271                 bindings.ChannelDetails_set_confirmations_required(this.ptr, val.ptr);
272         }
273
274         /**
275          * The number of blocks (after our commitment transaction confirms) that we will need to wait
276          * until we can claim our funds after we force-close the channel. During this time our
277          * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
278          * force-closes the channel and broadcasts a commitment transaction we do not have to wait any
279          * time to claim our non-HTLC-encumbered funds.
280          * 
281          * This value will be `None` for outbound channels until the counterparty accepts the channel.
282          */
283         public Option_u16Z get_force_close_spend_delay() {
284                 long ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr);
285                 if (ret >= 0 && ret <= 4096) { return null; }
286                 Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
287                 ret_hu_conv.ptrs_to.add(this);
288                 return ret_hu_conv;
289         }
290
291         /**
292          * The number of blocks (after our commitment transaction confirms) that we will need to wait
293          * until we can claim our funds after we force-close the channel. During this time our
294          * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
295          * force-closes the channel and broadcasts a commitment transaction we do not have to wait any
296          * time to claim our non-HTLC-encumbered funds.
297          * 
298          * This value will be `None` for outbound channels until the counterparty accepts the channel.
299          */
300         public void set_force_close_spend_delay(Option_u16Z val) {
301                 bindings.ChannelDetails_set_force_close_spend_delay(this.ptr, val.ptr);
302         }
303
304         /**
305          * True if the channel was initiated (and thus funded) by us.
306          */
307         public boolean get_is_outbound() {
308                 boolean ret = bindings.ChannelDetails_get_is_outbound(this.ptr);
309                 return ret;
310         }
311
312         /**
313          * True if the channel was initiated (and thus funded) by us.
314          */
315         public void set_is_outbound(boolean val) {
316                 bindings.ChannelDetails_set_is_outbound(this.ptr, val);
317         }
318
319         /**
320          * True if the channel is confirmed, funding_locked messages have been exchanged, and the
321          * channel is not currently being shut down. `funding_locked` message exchange implies the
322          * required confirmation count has been reached (and we were connected to the peer at some
323          * point after the funding transaction received enough confirmations). The required
324          * confirmation count is provided in [`confirmations_required`].
325          * 
326          * [`confirmations_required`]: ChannelDetails::confirmations_required
327          */
328         public boolean get_is_funding_locked() {
329                 boolean ret = bindings.ChannelDetails_get_is_funding_locked(this.ptr);
330                 return ret;
331         }
332
333         /**
334          * True if the channel is confirmed, funding_locked messages have been exchanged, and the
335          * channel is not currently being shut down. `funding_locked` message exchange implies the
336          * required confirmation count has been reached (and we were connected to the peer at some
337          * point after the funding transaction received enough confirmations). The required
338          * confirmation count is provided in [`confirmations_required`].
339          * 
340          * [`confirmations_required`]: ChannelDetails::confirmations_required
341          */
342         public void set_is_funding_locked(boolean val) {
343                 bindings.ChannelDetails_set_is_funding_locked(this.ptr, val);
344         }
345
346         /**
347          * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
348          * the peer is connected, and (c) the channel is not currently negotiating a shutdown.
349          * 
350          * This is a strict superset of `is_funding_locked`.
351          */
352         public boolean get_is_usable() {
353                 boolean ret = bindings.ChannelDetails_get_is_usable(this.ptr);
354                 return ret;
355         }
356
357         /**
358          * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
359          * the peer is connected, and (c) the channel is not currently negotiating a shutdown.
360          * 
361          * This is a strict superset of `is_funding_locked`.
362          */
363         public void set_is_usable(boolean val) {
364                 bindings.ChannelDetails_set_is_usable(this.ptr, val);
365         }
366
367         /**
368          * True if this channel is (or will be) publicly-announced.
369          */
370         public boolean get_is_public() {
371                 boolean ret = bindings.ChannelDetails_get_is_public(this.ptr);
372                 return ret;
373         }
374
375         /**
376          * True if this channel is (or will be) publicly-announced.
377          */
378         public void set_is_public(boolean val) {
379                 bindings.ChannelDetails_set_is_public(this.ptr, val);
380         }
381
382         /**
383          * Constructs a new ChannelDetails given each field
384          */
385         public static ChannelDetails of(byte[] channel_id_arg, ChannelCounterparty counterparty_arg, OutPoint funding_txo_arg, Option_u64Z short_channel_id_arg, long channel_value_satoshis_arg, Option_u64Z unspendable_punishment_reserve_arg, long user_channel_id_arg, long outbound_capacity_msat_arg, long inbound_capacity_msat_arg, Option_u32Z confirmations_required_arg, Option_u16Z force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg) {
386                 long ret = bindings.ChannelDetails_new(InternalUtils.check_arr_len(channel_id_arg, 32), counterparty_arg == null ? 0 : counterparty_arg.ptr & ~1, funding_txo_arg == null ? 0 : funding_txo_arg.ptr & ~1, short_channel_id_arg.ptr, channel_value_satoshis_arg, unspendable_punishment_reserve_arg.ptr, user_channel_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg.ptr, force_close_spend_delay_arg.ptr, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
387                 if (ret >= 0 && ret <= 4096) { return null; }
388                 ChannelDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelDetails(null, ret); }
389                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
390                 return ret_hu_conv;
391         }
392
393         long clone_ptr() {
394                 long ret = bindings.ChannelDetails_clone_ptr(this.ptr);
395                 return ret;
396         }
397
398         /**
399          * Creates a copy of the ChannelDetails
400          */
401         public ChannelDetails clone() {
402                 long ret = bindings.ChannelDetails_clone(this.ptr);
403                 if (ret >= 0 && ret <= 4096) { return null; }
404                 ChannelDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelDetails(null, ret); }
405                 ret_hu_conv.ptrs_to.add(this);
406                 return ret_hu_conv;
407         }
408
409 }