1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
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 {
20 if (ptr != 0) { bindings.ChannelDetails_free(ptr); }
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.
29 public byte[] get_channel_id() {
30 byte[] ret = bindings.ChannelDetails_get_channel_id(this.ptr);
31 Reference.reachabilityFence(this);
36 * The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
37 * thereafter this is the txid of the funding transaction xor the funding transaction output).
38 * Note that this means this value is *not* persistent - it can change once during the
39 * lifetime of the channel.
41 public void set_channel_id(byte[] val) {
42 bindings.ChannelDetails_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
43 Reference.reachabilityFence(this);
44 Reference.reachabilityFence(val);
48 * Parameters which apply to our counterparty. See individual fields for more information.
50 public ChannelCounterparty get_counterparty() {
51 long ret = bindings.ChannelDetails_get_counterparty(this.ptr);
52 Reference.reachabilityFence(this);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
55 ret_hu_conv.ptrs_to.add(this);
60 * Parameters which apply to our counterparty. See individual fields for more information.
62 public void set_counterparty(ChannelCounterparty val) {
63 bindings.ChannelDetails_set_counterparty(this.ptr, val == null ? 0 : val.ptr & ~1);
64 Reference.reachabilityFence(this);
65 Reference.reachabilityFence(val);
69 * The Channel's funding transaction output, if we've negotiated the funding transaction with
70 * our counterparty already.
72 * Note that, if this has been set, `channel_id` will be equivalent to
73 * `funding_txo.unwrap().to_channel_id()`.
75 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
78 public OutPoint get_funding_txo() {
79 long ret = bindings.ChannelDetails_get_funding_txo(this.ptr);
80 Reference.reachabilityFence(this);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
83 ret_hu_conv.ptrs_to.add(this);
88 * The Channel's funding transaction output, if we've negotiated the funding transaction with
89 * our counterparty already.
91 * Note that, if this has been set, `channel_id` will be equivalent to
92 * `funding_txo.unwrap().to_channel_id()`.
94 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
96 public void set_funding_txo(@Nullable OutPoint val) {
97 bindings.ChannelDetails_set_funding_txo(this.ptr, val == null ? 0 : val.ptr & ~1);
98 Reference.reachabilityFence(this);
99 Reference.reachabilityFence(val);
103 * The position of the funding transaction in the chain. None if the funding transaction has
104 * not yet been confirmed and the channel fully opened.
106 public Option_u64Z get_short_channel_id() {
107 long ret = bindings.ChannelDetails_get_short_channel_id(this.ptr);
108 Reference.reachabilityFence(this);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
111 ret_hu_conv.ptrs_to.add(this);
116 * The position of the funding transaction in the chain. None if the funding transaction has
117 * not yet been confirmed and the channel fully opened.
119 public void set_short_channel_id(Option_u64Z val) {
120 bindings.ChannelDetails_set_short_channel_id(this.ptr, val.ptr);
121 Reference.reachabilityFence(this);
122 Reference.reachabilityFence(val);
126 * The value, in satoshis, of this channel as appears in the funding output
128 public long get_channel_value_satoshis() {
129 long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr);
130 Reference.reachabilityFence(this);
135 * The value, in satoshis, of this channel as appears in the funding output
137 public void set_channel_value_satoshis(long val) {
138 bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val);
139 Reference.reachabilityFence(this);
140 Reference.reachabilityFence(val);
144 * The value, in satoshis, that must always be held in the channel for us. This value ensures
145 * that if we broadcast a revoked state, our counterparty can punish us by claiming at least
146 * this value on chain.
148 * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
150 * This value will be `None` for outbound channels until the counterparty accepts the channel.
152 * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
154 public Option_u64Z get_unspendable_punishment_reserve() {
155 long ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr);
156 Reference.reachabilityFence(this);
157 if (ret >= 0 && ret <= 4096) { return null; }
158 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
159 ret_hu_conv.ptrs_to.add(this);
164 * The value, in satoshis, that must always be held in the channel for us. This value ensures
165 * that if we broadcast a revoked state, our counterparty can punish us by claiming at least
166 * this value on chain.
168 * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
170 * This value will be `None` for outbound channels until the counterparty accepts the channel.
172 * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
174 public void set_unspendable_punishment_reserve(Option_u64Z val) {
175 bindings.ChannelDetails_set_unspendable_punishment_reserve(this.ptr, val.ptr);
176 Reference.reachabilityFence(this);
177 Reference.reachabilityFence(val);
181 * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound.
183 public long get_user_channel_id() {
184 long ret = bindings.ChannelDetails_get_user_channel_id(this.ptr);
185 Reference.reachabilityFence(this);
190 * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound.
192 public void set_user_channel_id(long val) {
193 bindings.ChannelDetails_set_user_channel_id(this.ptr, val);
194 Reference.reachabilityFence(this);
195 Reference.reachabilityFence(val);
199 * Our total balance. This is the amount we would get if we close the channel.
200 * This value is not exact. Due to various in-flight changes and feerate changes, exactly this
201 * amount is not likely to be recoverable on close.
203 * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
204 * balance is not available for inclusion in new outbound HTLCs). This further does not include
205 * any pending outgoing HTLCs which are awaiting some other resolution to be sent.
206 * This does not consider any on-chain fees.
208 * See also [`ChannelDetails::outbound_capacity_msat`]
210 public long get_balance_msat() {
211 long ret = bindings.ChannelDetails_get_balance_msat(this.ptr);
212 Reference.reachabilityFence(this);
217 * Our total balance. This is the amount we would get if we close the channel.
218 * This value is not exact. Due to various in-flight changes and feerate changes, exactly this
219 * amount is not likely to be recoverable on close.
221 * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
222 * balance is not available for inclusion in new outbound HTLCs). This further does not include
223 * any pending outgoing HTLCs which are awaiting some other resolution to be sent.
224 * This does not consider any on-chain fees.
226 * See also [`ChannelDetails::outbound_capacity_msat`]
228 public void set_balance_msat(long val) {
229 bindings.ChannelDetails_set_balance_msat(this.ptr, val);
230 Reference.reachabilityFence(this);
231 Reference.reachabilityFence(val);
235 * The available outbound capacity for sending HTLCs to the remote peer. This does not include
236 * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
237 * available for inclusion in new outbound HTLCs). This further does not include any pending
238 * outgoing HTLCs which are awaiting some other resolution to be sent.
240 * See also [`ChannelDetails::balance_msat`]
242 * This value is not exact. Due to various in-flight changes, feerate changes, and our
243 * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
244 * should be able to spend nearly this amount.
246 public long get_outbound_capacity_msat() {
247 long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this.ptr);
248 Reference.reachabilityFence(this);
253 * The available outbound capacity for sending HTLCs to the remote peer. This does not include
254 * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
255 * available for inclusion in new outbound HTLCs). This further does not include any pending
256 * outgoing HTLCs which are awaiting some other resolution to be sent.
258 * See also [`ChannelDetails::balance_msat`]
260 * This value is not exact. Due to various in-flight changes, feerate changes, and our
261 * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
262 * should be able to spend nearly this amount.
264 public void set_outbound_capacity_msat(long val) {
265 bindings.ChannelDetails_set_outbound_capacity_msat(this.ptr, val);
266 Reference.reachabilityFence(this);
267 Reference.reachabilityFence(val);
271 * The available inbound capacity for the remote peer to send HTLCs to us. This does not
272 * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
273 * available for inclusion in new inbound HTLCs).
274 * Note that there are some corner cases not fully handled here, so the actual available
275 * inbound capacity may be slightly higher than this.
277 * This value is not exact. Due to various in-flight changes, feerate changes, and our
278 * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
279 * However, our counterparty should be able to spend nearly this amount.
281 public long get_inbound_capacity_msat() {
282 long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this.ptr);
283 Reference.reachabilityFence(this);
288 * The available inbound capacity for the remote peer to send HTLCs to us. This does not
289 * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
290 * available for inclusion in new inbound HTLCs).
291 * Note that there are some corner cases not fully handled here, so the actual available
292 * inbound capacity may be slightly higher than this.
294 * This value is not exact. Due to various in-flight changes, feerate changes, and our
295 * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
296 * However, our counterparty should be able to spend nearly this amount.
298 public void set_inbound_capacity_msat(long val) {
299 bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val);
300 Reference.reachabilityFence(this);
301 Reference.reachabilityFence(val);
305 * The number of required confirmations on the funding transaction before the funding will be
306 * considered \"locked\". This number is selected by the channel fundee (i.e. us if
307 * [`is_outbound`] is *not* set), and can be selected for inbound channels with
308 * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
309 * [`ChannelHandshakeLimits::max_minimum_depth`].
311 * This value will be `None` for outbound channels until the counterparty accepts the channel.
313 * [`is_outbound`]: ChannelDetails::is_outbound
314 * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
315 * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
317 public Option_u32Z get_confirmations_required() {
318 long ret = bindings.ChannelDetails_get_confirmations_required(this.ptr);
319 Reference.reachabilityFence(this);
320 if (ret >= 0 && ret <= 4096) { return null; }
321 Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
322 ret_hu_conv.ptrs_to.add(this);
327 * The number of required confirmations on the funding transaction before the funding will be
328 * considered \"locked\". This number is selected by the channel fundee (i.e. us if
329 * [`is_outbound`] is *not* set), and can be selected for inbound channels with
330 * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
331 * [`ChannelHandshakeLimits::max_minimum_depth`].
333 * This value will be `None` for outbound channels until the counterparty accepts the channel.
335 * [`is_outbound`]: ChannelDetails::is_outbound
336 * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
337 * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
339 public void set_confirmations_required(Option_u32Z val) {
340 bindings.ChannelDetails_set_confirmations_required(this.ptr, val.ptr);
341 Reference.reachabilityFence(this);
342 Reference.reachabilityFence(val);
346 * The number of blocks (after our commitment transaction confirms) that we will need to wait
347 * until we can claim our funds after we force-close the channel. During this time our
348 * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
349 * force-closes the channel and broadcasts a commitment transaction we do not have to wait any
350 * time to claim our non-HTLC-encumbered funds.
352 * This value will be `None` for outbound channels until the counterparty accepts the channel.
354 public Option_u16Z get_force_close_spend_delay() {
355 long ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr);
356 Reference.reachabilityFence(this);
357 if (ret >= 0 && ret <= 4096) { return null; }
358 Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
359 ret_hu_conv.ptrs_to.add(this);
364 * The number of blocks (after our commitment transaction confirms) that we will need to wait
365 * until we can claim our funds after we force-close the channel. During this time our
366 * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
367 * force-closes the channel and broadcasts a commitment transaction we do not have to wait any
368 * time to claim our non-HTLC-encumbered funds.
370 * This value will be `None` for outbound channels until the counterparty accepts the channel.
372 public void set_force_close_spend_delay(Option_u16Z val) {
373 bindings.ChannelDetails_set_force_close_spend_delay(this.ptr, val.ptr);
374 Reference.reachabilityFence(this);
375 Reference.reachabilityFence(val);
379 * True if the channel was initiated (and thus funded) by us.
381 public boolean get_is_outbound() {
382 boolean ret = bindings.ChannelDetails_get_is_outbound(this.ptr);
383 Reference.reachabilityFence(this);
388 * True if the channel was initiated (and thus funded) by us.
390 public void set_is_outbound(boolean val) {
391 bindings.ChannelDetails_set_is_outbound(this.ptr, val);
392 Reference.reachabilityFence(this);
393 Reference.reachabilityFence(val);
397 * True if the channel is confirmed, funding_locked messages have been exchanged, and the
398 * channel is not currently being shut down. `funding_locked` message exchange implies the
399 * required confirmation count has been reached (and we were connected to the peer at some
400 * point after the funding transaction received enough confirmations). The required
401 * confirmation count is provided in [`confirmations_required`].
403 * [`confirmations_required`]: ChannelDetails::confirmations_required
405 public boolean get_is_funding_locked() {
406 boolean ret = bindings.ChannelDetails_get_is_funding_locked(this.ptr);
407 Reference.reachabilityFence(this);
412 * True if the channel is confirmed, funding_locked messages have been exchanged, and the
413 * channel is not currently being shut down. `funding_locked` message exchange implies the
414 * required confirmation count has been reached (and we were connected to the peer at some
415 * point after the funding transaction received enough confirmations). The required
416 * confirmation count is provided in [`confirmations_required`].
418 * [`confirmations_required`]: ChannelDetails::confirmations_required
420 public void set_is_funding_locked(boolean val) {
421 bindings.ChannelDetails_set_is_funding_locked(this.ptr, val);
422 Reference.reachabilityFence(this);
423 Reference.reachabilityFence(val);
427 * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
428 * the peer is connected, and (c) the channel is not currently negotiating a shutdown.
430 * This is a strict superset of `is_funding_locked`.
432 public boolean get_is_usable() {
433 boolean ret = bindings.ChannelDetails_get_is_usable(this.ptr);
434 Reference.reachabilityFence(this);
439 * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
440 * the peer is connected, and (c) the channel is not currently negotiating a shutdown.
442 * This is a strict superset of `is_funding_locked`.
444 public void set_is_usable(boolean val) {
445 bindings.ChannelDetails_set_is_usable(this.ptr, val);
446 Reference.reachabilityFence(this);
447 Reference.reachabilityFence(val);
451 * True if this channel is (or will be) publicly-announced.
453 public boolean get_is_public() {
454 boolean ret = bindings.ChannelDetails_get_is_public(this.ptr);
455 Reference.reachabilityFence(this);
460 * True if this channel is (or will be) publicly-announced.
462 public void set_is_public(boolean val) {
463 bindings.ChannelDetails_set_is_public(this.ptr, val);
464 Reference.reachabilityFence(this);
465 Reference.reachabilityFence(val);
469 * Constructs a new ChannelDetails given each field
471 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 balance_msat_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) {
472 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, balance_msat_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);
473 Reference.reachabilityFence(channel_id_arg);
474 Reference.reachabilityFence(counterparty_arg);
475 Reference.reachabilityFence(funding_txo_arg);
476 Reference.reachabilityFence(short_channel_id_arg);
477 Reference.reachabilityFence(channel_value_satoshis_arg);
478 Reference.reachabilityFence(unspendable_punishment_reserve_arg);
479 Reference.reachabilityFence(user_channel_id_arg);
480 Reference.reachabilityFence(balance_msat_arg);
481 Reference.reachabilityFence(outbound_capacity_msat_arg);
482 Reference.reachabilityFence(inbound_capacity_msat_arg);
483 Reference.reachabilityFence(confirmations_required_arg);
484 Reference.reachabilityFence(force_close_spend_delay_arg);
485 Reference.reachabilityFence(is_outbound_arg);
486 Reference.reachabilityFence(is_funding_locked_arg);
487 Reference.reachabilityFence(is_usable_arg);
488 Reference.reachabilityFence(is_public_arg);
489 if (ret >= 0 && ret <= 4096) { return null; }
490 ChannelDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelDetails(null, ret); }
491 ret_hu_conv.ptrs_to.add(ret_hu_conv);
496 long ret = bindings.ChannelDetails_clone_ptr(this.ptr);
497 Reference.reachabilityFence(this);
502 * Creates a copy of the ChannelDetails
504 public ChannelDetails clone() {
505 long ret = bindings.ChannelDetails_clone(this.ptr);
506 Reference.reachabilityFence(this);
507 if (ret >= 0 && ret <= 4096) { return null; }
508 ChannelDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelDetails(null, ret); }
509 ret_hu_conv.ptrs_to.add(this);