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 long ret = bindings.ChannelCounterparty_get_node_id(this.ptr);
25 if (ret >= 0 && ret <= 4096) { return null; }
26 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
31 * The node_id of our counterparty
33 public void set_node_id(byte[] val) {
34 bindings.ChannelCounterparty_set_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
40 * The Features the channel counterparty provided upon last connection.
41 * Useful for routing as it is the most up-to-date copy of the counterparty's features and
42 * many routing-relevant features are present in the init context.
44 public InitFeatures get_features() {
45 long ret = bindings.ChannelCounterparty_get_features(this.ptr);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
49 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
54 * The Features the channel counterparty provided upon last connection.
55 * Useful for routing as it is the most up-to-date copy of the counterparty's features and
56 * many routing-relevant features are present in the init context.
58 public void set_features(org.ldk.structs.InitFeatures val) {
59 bindings.ChannelCounterparty_set_features(this.ptr, val.ptr);
62 if (this != null) { this.ptrs_to.AddLast(val); };
66 * The value, in satoshis, that must always be held in the channel for our counterparty. This
67 * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
68 * claiming at least this value on chain.
70 * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
72 * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
74 public long get_unspendable_punishment_reserve() {
75 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
81 * The value, in satoshis, that must always be held in the channel for our counterparty. This
82 * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
83 * claiming at least this value on chain.
85 * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
87 * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
89 public void set_unspendable_punishment_reserve(long val) {
90 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
96 * Information on the fees and requirements that the counterparty requires when forwarding
97 * payments to us through this channel.
99 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
101 public CounterpartyForwardingInfo get_forwarding_info() {
102 long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 org.ldk.structs.CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyForwardingInfo(null, ret); }
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
111 * Information on the fees and requirements that the counterparty requires when forwarding
112 * payments to us through this channel.
114 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
116 public void set_forwarding_info(org.ldk.structs.CounterpartyForwardingInfo val) {
117 bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr);
120 if (this != null) { this.ptrs_to.AddLast(val); };
124 * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
125 * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
126 * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
128 public Option_u64Z get_outbound_htlc_minimum_msat() {
129 long ret = bindings.ChannelCounterparty_get_outbound_htlc_minimum_msat(this.ptr);
131 if (ret >= 0 && ret <= 4096) { return null; }
132 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
133 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
138 * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
139 * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
140 * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
142 public void set_outbound_htlc_minimum_msat(org.ldk.structs.Option_u64Z val) {
143 bindings.ChannelCounterparty_set_outbound_htlc_minimum_msat(this.ptr, val.ptr);
146 if (this != null) { this.ptrs_to.AddLast(val); };
150 * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
152 public Option_u64Z get_outbound_htlc_maximum_msat() {
153 long ret = bindings.ChannelCounterparty_get_outbound_htlc_maximum_msat(this.ptr);
155 if (ret >= 0 && ret <= 4096) { return null; }
156 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
162 * The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
164 public void set_outbound_htlc_maximum_msat(org.ldk.structs.Option_u64Z val) {
165 bindings.ChannelCounterparty_set_outbound_htlc_maximum_msat(this.ptr, val.ptr);
168 if (this != null) { this.ptrs_to.AddLast(val); };
172 * Constructs a new ChannelCounterparty given each field
174 * Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
176 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) {
177 long ret = bindings.ChannelCounterparty_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id_arg, 33)), 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);
178 GC.KeepAlive(node_id_arg);
179 GC.KeepAlive(features_arg);
180 GC.KeepAlive(unspendable_punishment_reserve_arg);
181 GC.KeepAlive(forwarding_info_arg);
182 GC.KeepAlive(outbound_htlc_minimum_msat_arg);
183 GC.KeepAlive(outbound_htlc_maximum_msat_arg);
184 if (ret >= 0 && ret <= 4096) { return null; }
185 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
186 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
187 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
188 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(forwarding_info_arg); };
189 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outbound_htlc_minimum_msat_arg); };
190 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outbound_htlc_maximum_msat_arg); };
194 internal long clone_ptr() {
195 long ret = bindings.ChannelCounterparty_clone_ptr(this.ptr);
201 * Creates a copy of the ChannelCounterparty
203 public ChannelCounterparty clone() {
204 long ret = bindings.ChannelCounterparty_clone(this.ptr);
206 if (ret >= 0 && ret <= 4096) { return null; }
207 org.ldk.structs.ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelCounterparty(null, ret); }
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
213 * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
215 public byte[] write() {
216 long ret = bindings.ChannelCounterparty_write(this.ptr);
218 if (ret >= 0 && ret <= 4096) { return null; }
219 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
224 * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
226 public static Result_ChannelCounterpartyDecodeErrorZ read(byte[] ser) {
227 long ret = bindings.ChannelCounterparty_read(InternalUtils.encodeUint8Array(ser));
229 if (ret >= 0 && ret <= 4096) { return null; }
230 Result_ChannelCounterpartyDecodeErrorZ ret_hu_conv = Result_ChannelCounterpartyDecodeErrorZ.constr_from_ptr(ret);