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