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 * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
12 * to better separate parameters.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelCounterparty extends CommonBase {
16 ChannelCounterparty(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelCounterparty_free(ptr); }
24 * The node_id of our counterparty
26 public byte[] get_node_id() {
27 byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr);
32 * The node_id of our counterparty
34 public void set_node_id(byte[] val) {
35 bindings.ChannelCounterparty_set_node_id(this.ptr, val);
39 * The Features the channel counterparty provided upon last connection.
40 * Useful for routing as it is the most up-to-date copy of the counterparty's features and
41 * many routing-relevant features are present in the init context.
43 public InitFeatures get_features() {
44 long ret = bindings.ChannelCounterparty_get_features(this.ptr);
45 if (ret < 1024) { return null; }
46 InitFeatures ret_hu_conv = new InitFeatures(null, ret);
47 ret_hu_conv.ptrs_to.add(this);
52 * The Features the channel counterparty provided upon last connection.
53 * Useful for routing as it is the most up-to-date copy of the counterparty's features and
54 * many routing-relevant features are present in the init context.
56 public void set_features(InitFeatures val) {
57 bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
58 this.ptrs_to.add(val);
62 * The value, in satoshis, that must always be held in the channel for our counterparty. This
63 * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
64 * claiming at least this value on chain.
66 * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
68 * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
70 public long get_unspendable_punishment_reserve() {
71 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
76 * The value, in satoshis, that must always be held in the channel for our counterparty. This
77 * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
78 * claiming at least this value on chain.
80 * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
82 * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
84 public void set_unspendable_punishment_reserve(long val) {
85 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
89 * Information on the fees and requirements that the counterparty requires when forwarding
90 * payments to us through this channel.
92 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
95 public CounterpartyForwardingInfo get_forwarding_info() {
96 long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
97 if (ret < 1024) { return null; }
98 CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret);
99 ret_hu_conv.ptrs_to.add(this);
104 * Information on the fees and requirements that the counterparty requires when forwarding
105 * payments to us through this channel.
107 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
109 public void set_forwarding_info(@Nullable CounterpartyForwardingInfo val) {
110 bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr & ~1);
111 this.ptrs_to.add(val);
115 * Constructs a new ChannelCounterparty given each field
117 public static ChannelCounterparty of(byte[] node_id_arg, InitFeatures features_arg, long unspendable_punishment_reserve_arg, CounterpartyForwardingInfo forwarding_info_arg) {
118 long ret = bindings.ChannelCounterparty_new(node_id_arg, features_arg == null ? 0 : features_arg.ptr & ~1, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr & ~1);
119 if (ret < 1024) { return null; }
120 ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret);
121 ret_hu_conv.ptrs_to.add(ret_hu_conv);
122 ret_hu_conv.ptrs_to.add(features_arg);
123 ret_hu_conv.ptrs_to.add(forwarding_info_arg);
128 * Creates a copy of the ChannelCounterparty
130 public ChannelCounterparty clone() {
131 long ret = bindings.ChannelCounterparty_clone(this.ptr);
132 if (ret < 1024) { return null; }
133 ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret);
134 ret_hu_conv.ptrs_to.add(this);