1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
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 {
19 if (ptr != 0) { bindings.ChannelDetails_free(ptr); }
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.
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.ChannelDetails_get_channel_id(this.ptr);
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.
39 public void set_channel_id(byte[] val) {
40 bindings.ChannelDetails_set_channel_id(this.ptr, val);
44 * Parameters which apply to our counterparty. See individual fields for more information.
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);
55 * Parameters which apply to our counterparty. See individual fields for more information.
57 public void set_counterparty(ChannelCounterparty val) {
58 bindings.ChannelDetails_set_counterparty(this.ptr, val == null ? 0 : val.ptr & ~1);
62 * The Channel's funding transaction output, if we've negotiated the funding transaction with
63 * our counterparty already.
65 * Note that, if this has been set, `channel_id` will be equivalent to
66 * `funding_txo.unwrap().to_channel_id()`.
68 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
71 public OutPoint get_funding_txo() {
72 long ret = bindings.ChannelDetails_get_funding_txo(this.ptr);
73 if (ret < 1024) { return null; }
74 OutPoint ret_hu_conv = new OutPoint(null, ret);
75 ret_hu_conv.ptrs_to.add(this);
80 * The Channel's funding transaction output, if we've negotiated the funding transaction with
81 * our counterparty already.
83 * Note that, if this has been set, `channel_id` will be equivalent to
84 * `funding_txo.unwrap().to_channel_id()`.
86 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
88 public void set_funding_txo(@Nullable OutPoint val) {
89 bindings.ChannelDetails_set_funding_txo(this.ptr, val == null ? 0 : val.ptr & ~1);
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.
96 public Option_u64Z get_short_channel_id() {
97 long ret = bindings.ChannelDetails_get_short_channel_id(this.ptr);
98 if (ret < 1024) { return null; }
99 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
100 ret_hu_conv.ptrs_to.add(this);
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.
108 public void set_short_channel_id(Option_u64Z val) {
109 bindings.ChannelDetails_set_short_channel_id(this.ptr, val.ptr);
113 * The value, in satoshis, of this channel as appears in the funding output
115 public long get_channel_value_satoshis() {
116 long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr);
121 * The value, in satoshis, of this channel as appears in the funding output
123 public void set_channel_value_satoshis(long val) {
124 bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val);
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.
132 * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
134 * This value will be `None` for outbound channels until the counterparty accepts the channel.
136 * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
138 public Option_u64Z get_unspendable_punishment_reserve() {
139 long ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr);
140 if (ret < 1024) { return null; }
141 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
142 ret_hu_conv.ptrs_to.add(this);
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.
151 * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
153 * This value will be `None` for outbound channels until the counterparty accepts the channel.
155 * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
157 public void set_unspendable_punishment_reserve(Option_u64Z val) {
158 bindings.ChannelDetails_set_unspendable_punishment_reserve(this.ptr, val.ptr);
162 * The user_id passed in to create_channel, or 0 if the channel was inbound.
164 public long get_user_id() {
165 long ret = bindings.ChannelDetails_get_user_id(this.ptr);
170 * The user_id passed in to create_channel, or 0 if the channel was inbound.
172 public void set_user_id(long val) {
173 bindings.ChannelDetails_set_user_id(this.ptr, val);
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.
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.
186 public long get_outbound_capacity_msat() {
187 long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this.ptr);
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.
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.
201 public void set_outbound_capacity_msat(long val) {
202 bindings.ChannelDetails_set_outbound_capacity_msat(this.ptr, val);
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.
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.
216 public long get_inbound_capacity_msat() {
217 long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this.ptr);
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.
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.
232 public void set_inbound_capacity_msat(long val) {
233 bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val);
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`].
243 * This value will be `None` for outbound channels until the counterparty accepts the channel.
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
249 public Option_u32Z get_confirmations_required() {
250 long ret = bindings.ChannelDetails_get_confirmations_required(this.ptr);
251 if (ret < 1024) { return null; }
252 Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
253 ret_hu_conv.ptrs_to.add(this);
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`].
264 * This value will be `None` for outbound channels until the counterparty accepts the channel.
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
270 public void set_confirmations_required(Option_u32Z val) {
271 bindings.ChannelDetails_set_confirmations_required(this.ptr, val.ptr);
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.
281 * This value will be `None` for outbound channels until the counterparty accepts the channel.
283 public Option_u16Z get_force_close_spend_delay() {
284 long ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr);
285 if (ret < 1024) { return null; }
286 Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
287 ret_hu_conv.ptrs_to.add(this);
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.
298 * This value will be `None` for outbound channels until the counterparty accepts the channel.
300 public void set_force_close_spend_delay(Option_u16Z val) {
301 bindings.ChannelDetails_set_force_close_spend_delay(this.ptr, val.ptr);
305 * True if the channel was initiated (and thus funded) by us.
307 public boolean get_is_outbound() {
308 boolean ret = bindings.ChannelDetails_get_is_outbound(this.ptr);
313 * True if the channel was initiated (and thus funded) by us.
315 public void set_is_outbound(boolean val) {
316 bindings.ChannelDetails_set_is_outbound(this.ptr, val);
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`].
326 * [`confirmations_required`]: ChannelDetails::confirmations_required
328 public boolean get_is_funding_locked() {
329 boolean ret = bindings.ChannelDetails_get_is_funding_locked(this.ptr);
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`].
340 * [`confirmations_required`]: ChannelDetails::confirmations_required
342 public void set_is_funding_locked(boolean val) {
343 bindings.ChannelDetails_set_is_funding_locked(this.ptr, val);
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.
350 * This is a strict superset of `is_funding_locked`.
352 public boolean get_is_usable() {
353 boolean ret = bindings.ChannelDetails_get_is_usable(this.ptr);
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.
361 * This is a strict superset of `is_funding_locked`.
363 public void set_is_usable(boolean val) {
364 bindings.ChannelDetails_set_is_usable(this.ptr, val);
368 * True if this channel is (or will be) publicly-announced.
370 public boolean get_is_public() {
371 boolean ret = bindings.ChannelDetails_get_is_public(this.ptr);
376 * True if this channel is (or will be) publicly-announced.
378 public void set_is_public(boolean val) {
379 bindings.ChannelDetails_set_is_public(this.ptr, val);
383 * Constructs a new ChannelDetails given each field
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_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(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);
387 if (ret < 1024) { return null; }
388 ChannelDetails ret_hu_conv = new ChannelDetails(null, ret);
389 ret_hu_conv.ptrs_to.add(ret_hu_conv);
394 * Creates a copy of the ChannelDetails
396 public ChannelDetails clone() {
397 long ret = bindings.ChannelDetails_clone(this.ptr);
398 if (ret < 1024) { return null; }
399 ChannelDetails ret_hu_conv = new ChannelDetails(null, ret);
400 ret_hu_conv.ptrs_to.add(this);