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