6 namespace org { namespace ldk { namespace structs {
10 * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
11 * to better separate parameters.
13 public class ChannelCounterparty : CommonBase {
14 internal ChannelCounterparty(object _dummy, long ptr) : base(ptr) { }
15 ~ChannelCounterparty() {
16 if (ptr != 0) { bindings.ChannelCounterparty_free(ptr); }
20 * The node_id of our counterparty
22 public byte[] get_node_id() {
23 byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr);
29 * The node_id of our counterparty
31 public void set_node_id(byte[] val) {
32 bindings.ChannelCounterparty_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
38 * The Features the channel counterparty provided upon last connection.
39 * Useful for routing as it is the most up-to-date copy of the counterparty's features and
40 * many routing-relevant features are present in the init context.
42 public InitFeatures get_features() {
43 long ret = bindings.ChannelCounterparty_get_features(this.ptr);
45 if (ret >= 0 && ret <= 4096) { return null; }
46 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
47 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(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(org.ldk.structs.InitFeatures val) {
57 bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr);
60 if (this != null) { this.ptrs_to.AddLast(val); };
64 * The value, in satoshis, that must always be held in the channel for our counterparty. This
65 * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
66 * claiming at least this value on chain.
68 * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
70 * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
72 public long get_unspendable_punishment_reserve() {
73 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
79 * The value, in satoshis, that must always be held in the channel for our counterparty. This
80 * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
81 * claiming at least this value on chain.
83 * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
85 * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
87 public void set_unspendable_punishment_reserve(long val) {
88 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
94 * Information on the fees and requirements that the counterparty requires when forwarding
95 * payments to us through this channel.
97 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
99 public CounterpartyForwardingInfo get_forwarding_info() {
100 long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 org.ldk.structs.CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyForwardingInfo(null, ret); }
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109 * Information on the fees and requirements that the counterparty requires when forwarding
110 * payments to us through this channel.
112 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
114 public void set_forwarding_info(org.ldk.structs.CounterpartyForwardingInfo val) {
115 bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr);
118 if (this != null) { this.ptrs_to.AddLast(val); };
122 * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
123 * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
124 * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
126 public Option_u64Z get_outbound_htlc_minimum_msat() {
127 long ret = bindings.ChannelCounterparty_get_outbound_htlc_minimum_msat(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
136 * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
137 * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
138 * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
140 public void set_outbound_htlc_minimum_msat(org.ldk.structs.Option_u64Z val) {
141 bindings.ChannelCounterparty_set_outbound_htlc_minimum_msat(this.ptr, val.ptr);
147 * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
149 public Option_u64Z get_outbound_htlc_maximum_msat() {
150 long ret = bindings.ChannelCounterparty_get_outbound_htlc_maximum_msat(this.ptr);
152 if (ret >= 0 && ret <= 4096) { return null; }
153 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
154 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
159 * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
161 public void set_outbound_htlc_maximum_msat(org.ldk.structs.Option_u64Z val) {
162 bindings.ChannelCounterparty_set_outbound_htlc_maximum_msat(this.ptr, val.ptr);
168 * Constructs a new ChannelCounterparty given each field
170 public static ChannelCounterparty of(byte[] node_id_arg, org.ldk.structs.InitFeatures features_arg, long unspendable_punishment_reserve_arg, org.ldk.structs.CounterpartyForwardingInfo forwarding_info_arg, org.ldk.structs.Option_u64Z outbound_htlc_minimum_msat_arg, org.ldk.structs.Option_u64Z outbound_htlc_maximum_msat_arg) {
171 long ret = bindings.ChannelCounterparty_new(InternalUtils.check_arr_len(node_id_arg, 33), features_arg == null ? 0 : features_arg.ptr, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr, outbound_htlc_minimum_msat_arg.ptr, outbound_htlc_maximum_msat_arg.ptr);
172 GC.KeepAlive(node_id_arg);
173 GC.KeepAlive(features_arg);
174 GC.KeepAlive(unspendable_punishment_reserve_arg);
175 GC.KeepAlive(forwarding_info_arg);
176 GC.KeepAlive(outbound_htlc_minimum_msat_arg);
177 GC.KeepAlive(outbound_htlc_maximum_msat_arg);
178 if (ret >= 0 && ret <= 4096) { return null; }
179 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
181 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
182 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(forwarding_info_arg); };
186 internal long clone_ptr() {
187 long ret = bindings.ChannelCounterparty_clone_ptr(this.ptr);
193 * Creates a copy of the ChannelCounterparty
195 public ChannelCounterparty clone() {
196 long ret = bindings.ChannelCounterparty_clone(this.ptr);
198 if (ret >= 0 && ret <= 4096) { return null; }
199 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
200 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
205 * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
207 public byte[] write() {
208 byte[] ret = bindings.ChannelCounterparty_write(this.ptr);
214 * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
216 public static Result_ChannelCounterpartyDecodeErrorZ read(byte[] ser) {
217 long ret = bindings.ChannelCounterparty_read(ser);
219 if (ret >= 0 && ret <= 4096) { return null; }
220 Result_ChannelCounterpartyDecodeErrorZ ret_hu_conv = Result_ChannelCounterpartyDecodeErrorZ.constr_from_ptr(ret);