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 * Contains fields that are both common to [`accept_channel`] and `accept_channel2` messages.
14 * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class CommonAcceptChannelFields extends CommonBase {
18 CommonAcceptChannelFields(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.CommonAcceptChannelFields_free(ptr); }
26 * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
28 public ChannelId get_temporary_channel_id() {
29 long ret = bindings.CommonAcceptChannelFields_get_temporary_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38 * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
40 public void set_temporary_channel_id(org.ldk.structs.ChannelId val) {
41 bindings.CommonAcceptChannelFields_set_temporary_channel_id(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * The threshold below which outputs on transactions broadcast by the channel acceptor will be
51 public long get_dust_limit_satoshis() {
52 long ret = bindings.CommonAcceptChannelFields_get_dust_limit_satoshis(this.ptr);
53 Reference.reachabilityFence(this);
58 * The threshold below which outputs on transactions broadcast by the channel acceptor will be
61 public void set_dust_limit_satoshis(long val) {
62 bindings.CommonAcceptChannelFields_set_dust_limit_satoshis(this.ptr, val);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
68 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
70 public long get_max_htlc_value_in_flight_msat() {
71 long ret = bindings.CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(this.ptr);
72 Reference.reachabilityFence(this);
77 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
79 public void set_max_htlc_value_in_flight_msat(long val) {
80 bindings.CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(this.ptr, val);
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(val);
86 * The minimum HTLC size incoming to channel acceptor, in milli-satoshi
88 public long get_htlc_minimum_msat() {
89 long ret = bindings.CommonAcceptChannelFields_get_htlc_minimum_msat(this.ptr);
90 Reference.reachabilityFence(this);
95 * The minimum HTLC size incoming to channel acceptor, in milli-satoshi
97 public void set_htlc_minimum_msat(long val) {
98 bindings.CommonAcceptChannelFields_set_htlc_minimum_msat(this.ptr, val);
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(val);
104 * Minimum depth of the funding transaction before the channel is considered open
106 public int get_minimum_depth() {
107 int ret = bindings.CommonAcceptChannelFields_get_minimum_depth(this.ptr);
108 Reference.reachabilityFence(this);
113 * Minimum depth of the funding transaction before the channel is considered open
115 public void set_minimum_depth(int val) {
116 bindings.CommonAcceptChannelFields_set_minimum_depth(this.ptr, val);
117 Reference.reachabilityFence(this);
118 Reference.reachabilityFence(val);
122 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
123 * broadcast a commitment transaction
125 public short get_to_self_delay() {
126 short ret = bindings.CommonAcceptChannelFields_get_to_self_delay(this.ptr);
127 Reference.reachabilityFence(this);
132 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
133 * broadcast a commitment transaction
135 public void set_to_self_delay(short val) {
136 bindings.CommonAcceptChannelFields_set_to_self_delay(this.ptr, val);
137 Reference.reachabilityFence(this);
138 Reference.reachabilityFence(val);
142 * The maximum number of inbound HTLCs towards channel acceptor
144 public short get_max_accepted_htlcs() {
145 short ret = bindings.CommonAcceptChannelFields_get_max_accepted_htlcs(this.ptr);
146 Reference.reachabilityFence(this);
151 * The maximum number of inbound HTLCs towards channel acceptor
153 public void set_max_accepted_htlcs(short val) {
154 bindings.CommonAcceptChannelFields_set_max_accepted_htlcs(this.ptr, val);
155 Reference.reachabilityFence(this);
156 Reference.reachabilityFence(val);
160 * The channel acceptor's key controlling the funding transaction
162 public byte[] get_funding_pubkey() {
163 byte[] ret = bindings.CommonAcceptChannelFields_get_funding_pubkey(this.ptr);
164 Reference.reachabilityFence(this);
169 * The channel acceptor's key controlling the funding transaction
171 public void set_funding_pubkey(byte[] val) {
172 bindings.CommonAcceptChannelFields_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
173 Reference.reachabilityFence(this);
174 Reference.reachabilityFence(val);
178 * Used to derive a revocation key for transactions broadcast by counterparty
180 public byte[] get_revocation_basepoint() {
181 byte[] ret = bindings.CommonAcceptChannelFields_get_revocation_basepoint(this.ptr);
182 Reference.reachabilityFence(this);
187 * Used to derive a revocation key for transactions broadcast by counterparty
189 public void set_revocation_basepoint(byte[] val) {
190 bindings.CommonAcceptChannelFields_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
191 Reference.reachabilityFence(this);
192 Reference.reachabilityFence(val);
196 * A payment key to channel acceptor for transactions broadcast by counterparty
198 public byte[] get_payment_basepoint() {
199 byte[] ret = bindings.CommonAcceptChannelFields_get_payment_basepoint(this.ptr);
200 Reference.reachabilityFence(this);
205 * A payment key to channel acceptor for transactions broadcast by counterparty
207 public void set_payment_basepoint(byte[] val) {
208 bindings.CommonAcceptChannelFields_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
209 Reference.reachabilityFence(this);
210 Reference.reachabilityFence(val);
214 * Used to derive a payment key to channel acceptor for transactions broadcast by channel
217 public byte[] get_delayed_payment_basepoint() {
218 byte[] ret = bindings.CommonAcceptChannelFields_get_delayed_payment_basepoint(this.ptr);
219 Reference.reachabilityFence(this);
224 * Used to derive a payment key to channel acceptor for transactions broadcast by channel
227 public void set_delayed_payment_basepoint(byte[] val) {
228 bindings.CommonAcceptChannelFields_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
229 Reference.reachabilityFence(this);
230 Reference.reachabilityFence(val);
234 * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
236 public byte[] get_htlc_basepoint() {
237 byte[] ret = bindings.CommonAcceptChannelFields_get_htlc_basepoint(this.ptr);
238 Reference.reachabilityFence(this);
243 * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
245 public void set_htlc_basepoint(byte[] val) {
246 bindings.CommonAcceptChannelFields_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
247 Reference.reachabilityFence(this);
248 Reference.reachabilityFence(val);
252 * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
254 public byte[] get_first_per_commitment_point() {
255 byte[] ret = bindings.CommonAcceptChannelFields_get_first_per_commitment_point(this.ptr);
256 Reference.reachabilityFence(this);
261 * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
263 public void set_first_per_commitment_point(byte[] val) {
264 bindings.CommonAcceptChannelFields_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
265 Reference.reachabilityFence(this);
266 Reference.reachabilityFence(val);
270 * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
271 * collaboratively close
273 public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
274 long ret = bindings.CommonAcceptChannelFields_get_shutdown_scriptpubkey(this.ptr);
275 Reference.reachabilityFence(this);
276 if (ret >= 0 && ret <= 4096) { return null; }
277 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
278 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
283 * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
284 * collaboratively close
286 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
287 bindings.CommonAcceptChannelFields_set_shutdown_scriptpubkey(this.ptr, val.ptr);
288 Reference.reachabilityFence(this);
289 Reference.reachabilityFence(val);
290 if (this != null) { this.ptrs_to.add(val); };
294 * The channel type that this channel will represent. If none is set, we derive the channel
295 * type from the intersection of our feature bits with our counterparty's feature bits from
298 * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
299 * [`CommonOpenChannelFields::channel_type`].
301 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
304 public ChannelTypeFeatures get_channel_type() {
305 long ret = bindings.CommonAcceptChannelFields_get_channel_type(this.ptr);
306 Reference.reachabilityFence(this);
307 if (ret >= 0 && ret <= 4096) { return null; }
308 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
309 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
314 * The channel type that this channel will represent. If none is set, we derive the channel
315 * type from the intersection of our feature bits with our counterparty's feature bits from
318 * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
319 * [`CommonOpenChannelFields::channel_type`].
321 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
323 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
324 bindings.CommonAcceptChannelFields_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
325 Reference.reachabilityFence(this);
326 Reference.reachabilityFence(val);
327 if (this != null) { this.ptrs_to.add(val); };
331 * Constructs a new CommonAcceptChannelFields given each field
333 * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
335 public static CommonAcceptChannelFields of(org.ldk.structs.ChannelId temporary_channel_id_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long htlc_minimum_msat_arg, int minimum_depth_arg, short to_self_delay_arg, short max_accepted_htlcs_arg, byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_basepoint_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg, byte[] first_per_commitment_point_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
336 long ret = bindings.CommonAcceptChannelFields_new(temporary_channel_id_arg.ptr, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, InternalUtils.check_arr_len(funding_pubkey_arg, 33), InternalUtils.check_arr_len(revocation_basepoint_arg, 33), InternalUtils.check_arr_len(payment_basepoint_arg, 33), InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33), InternalUtils.check_arr_len(htlc_basepoint_arg, 33), InternalUtils.check_arr_len(first_per_commitment_point_arg, 33), shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
337 Reference.reachabilityFence(temporary_channel_id_arg);
338 Reference.reachabilityFence(dust_limit_satoshis_arg);
339 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
340 Reference.reachabilityFence(htlc_minimum_msat_arg);
341 Reference.reachabilityFence(minimum_depth_arg);
342 Reference.reachabilityFence(to_self_delay_arg);
343 Reference.reachabilityFence(max_accepted_htlcs_arg);
344 Reference.reachabilityFence(funding_pubkey_arg);
345 Reference.reachabilityFence(revocation_basepoint_arg);
346 Reference.reachabilityFence(payment_basepoint_arg);
347 Reference.reachabilityFence(delayed_payment_basepoint_arg);
348 Reference.reachabilityFence(htlc_basepoint_arg);
349 Reference.reachabilityFence(first_per_commitment_point_arg);
350 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
351 Reference.reachabilityFence(channel_type_arg);
352 if (ret >= 0 && ret <= 4096) { return null; }
353 org.ldk.structs.CommonAcceptChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonAcceptChannelFields(null, ret); }
354 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
355 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(temporary_channel_id_arg); };
356 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
357 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
362 long ret = bindings.CommonAcceptChannelFields_clone_ptr(this.ptr);
363 Reference.reachabilityFence(this);
368 * Creates a copy of the CommonAcceptChannelFields
370 public CommonAcceptChannelFields clone() {
371 long ret = bindings.CommonAcceptChannelFields_clone(this.ptr);
372 Reference.reachabilityFence(this);
373 if (ret >= 0 && ret <= 4096) { return null; }
374 org.ldk.structs.CommonAcceptChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonAcceptChannelFields(null, ret); }
375 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
380 * Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields.
383 long ret = bindings.CommonAcceptChannelFields_hash(this.ptr);
384 Reference.reachabilityFence(this);
388 @Override public int hashCode() {
389 return (int)this.hash();
392 * Checks if two CommonAcceptChannelFieldss contain equal inner contents.
393 * This ignores pointers and is_owned flags and looks at the values in fields.
394 * Two objects with NULL inner values will be considered "equal" here.
396 public boolean eq(org.ldk.structs.CommonAcceptChannelFields b) {
397 boolean ret = bindings.CommonAcceptChannelFields_eq(this.ptr, b.ptr);
398 Reference.reachabilityFence(this);
399 Reference.reachabilityFence(b);
400 if (this != null) { this.ptrs_to.add(b); };
404 @Override public boolean equals(Object o) {
405 if (!(o instanceof CommonAcceptChannelFields)) return false;
406 return this.eq((CommonAcceptChannelFields)o);