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 * A wrapper around [`ChannelInfo`] representing information about the channel as directed from a
13 * source node to a target node.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class DirectedChannelInfo extends CommonBase {
17 DirectedChannelInfo(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.DirectedChannelInfo_free(ptr); }
25 long ret = bindings.DirectedChannelInfo_clone_ptr(this.ptr);
26 Reference.reachabilityFence(this);
31 * Creates a copy of the DirectedChannelInfo
33 public DirectedChannelInfo clone() {
34 long ret = bindings.DirectedChannelInfo_clone(this.ptr);
35 Reference.reachabilityFence(this);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 DirectedChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelInfo(null, ret); }
38 ret_hu_conv.ptrs_to.add(this);
43 * Returns information for the channel.
45 public ChannelInfo channel() {
46 long ret = bindings.DirectedChannelInfo_channel(this.ptr);
47 Reference.reachabilityFence(this);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
50 ret_hu_conv.ptrs_to.add(this);
55 * Returns information for the direction.
57 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
60 public ChannelUpdateInfo direction() {
61 long ret = bindings.DirectedChannelInfo_direction(this.ptr);
62 Reference.reachabilityFence(this);
63 if (ret >= 0 && ret <= 4096) { return null; }
64 ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdateInfo(null, ret); }
65 ret_hu_conv.ptrs_to.add(this);
70 * Returns the [`EffectiveCapacity`] of the channel in the direction.
72 * This is either the total capacity from the funding transaction, if known, or the
73 * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known,
74 * whichever is smaller.
76 public EffectiveCapacity effective_capacity() {
77 long ret = bindings.DirectedChannelInfo_effective_capacity(this.ptr);
78 Reference.reachabilityFence(this);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
81 ret_hu_conv.ptrs_to.add(this);