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 * An accept_channel2 message to be sent by or received from the channel accepter.
14 * Used in V2 channel establishment
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class AcceptChannelV2 extends CommonBase {
18 AcceptChannelV2(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.AcceptChannelV2_free(ptr); }
26 * The same `temporary_channel_id` received from the initiator's `open_channel2` message.
28 public byte[] get_temporary_channel_id() {
29 byte[] ret = bindings.AcceptChannelV2_get_temporary_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
35 * The same `temporary_channel_id` received from the initiator's `open_channel2` message.
37 public void set_temporary_channel_id(byte[] val) {
38 bindings.AcceptChannelV2_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * Part of the channel value contributed by the channel acceptor
46 public long get_funding_satoshis() {
47 long ret = bindings.AcceptChannelV2_get_funding_satoshis(this.ptr);
48 Reference.reachabilityFence(this);
53 * Part of the channel value contributed by the channel acceptor
55 public void set_funding_satoshis(long val) {
56 bindings.AcceptChannelV2_set_funding_satoshis(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The threshold below which outputs on transactions broadcast by the channel acceptor will be
65 public long get_dust_limit_satoshis() {
66 long ret = bindings.AcceptChannelV2_get_dust_limit_satoshis(this.ptr);
67 Reference.reachabilityFence(this);
72 * The threshold below which outputs on transactions broadcast by the channel acceptor will be
75 public void set_dust_limit_satoshis(long val) {
76 bindings.AcceptChannelV2_set_dust_limit_satoshis(this.ptr, val);
77 Reference.reachabilityFence(this);
78 Reference.reachabilityFence(val);
82 * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
84 public long get_max_htlc_value_in_flight_msat() {
85 long ret = bindings.AcceptChannelV2_get_max_htlc_value_in_flight_msat(this.ptr);
86 Reference.reachabilityFence(this);
91 * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
93 public void set_max_htlc_value_in_flight_msat(long val) {
94 bindings.AcceptChannelV2_set_max_htlc_value_in_flight_msat(this.ptr, val);
95 Reference.reachabilityFence(this);
96 Reference.reachabilityFence(val);
100 * The minimum HTLC size incoming to channel acceptor, in milli-satoshi
102 public long get_htlc_minimum_msat() {
103 long ret = bindings.AcceptChannelV2_get_htlc_minimum_msat(this.ptr);
104 Reference.reachabilityFence(this);
109 * The minimum HTLC size incoming to channel acceptor, in milli-satoshi
111 public void set_htlc_minimum_msat(long val) {
112 bindings.AcceptChannelV2_set_htlc_minimum_msat(this.ptr, val);
113 Reference.reachabilityFence(this);
114 Reference.reachabilityFence(val);
118 * Minimum depth of the funding transaction before the channel is considered open
120 public int get_minimum_depth() {
121 int ret = bindings.AcceptChannelV2_get_minimum_depth(this.ptr);
122 Reference.reachabilityFence(this);
127 * Minimum depth of the funding transaction before the channel is considered open
129 public void set_minimum_depth(int val) {
130 bindings.AcceptChannelV2_set_minimum_depth(this.ptr, val);
131 Reference.reachabilityFence(this);
132 Reference.reachabilityFence(val);
136 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
137 * broadcast a commitment transaction
139 public short get_to_self_delay() {
140 short ret = bindings.AcceptChannelV2_get_to_self_delay(this.ptr);
141 Reference.reachabilityFence(this);
146 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
147 * broadcast a commitment transaction
149 public void set_to_self_delay(short val) {
150 bindings.AcceptChannelV2_set_to_self_delay(this.ptr, val);
151 Reference.reachabilityFence(this);
152 Reference.reachabilityFence(val);
156 * The maximum number of inbound HTLCs towards channel acceptor
158 public short get_max_accepted_htlcs() {
159 short ret = bindings.AcceptChannelV2_get_max_accepted_htlcs(this.ptr);
160 Reference.reachabilityFence(this);
165 * The maximum number of inbound HTLCs towards channel acceptor
167 public void set_max_accepted_htlcs(short val) {
168 bindings.AcceptChannelV2_set_max_accepted_htlcs(this.ptr, val);
169 Reference.reachabilityFence(this);
170 Reference.reachabilityFence(val);
174 * The channel acceptor's key controlling the funding transaction
176 public byte[] get_funding_pubkey() {
177 byte[] ret = bindings.AcceptChannelV2_get_funding_pubkey(this.ptr);
178 Reference.reachabilityFence(this);
183 * The channel acceptor's key controlling the funding transaction
185 public void set_funding_pubkey(byte[] val) {
186 bindings.AcceptChannelV2_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
187 Reference.reachabilityFence(this);
188 Reference.reachabilityFence(val);
192 * Used to derive a revocation key for transactions broadcast by counterparty
194 public byte[] get_revocation_basepoint() {
195 byte[] ret = bindings.AcceptChannelV2_get_revocation_basepoint(this.ptr);
196 Reference.reachabilityFence(this);
201 * Used to derive a revocation key for transactions broadcast by counterparty
203 public void set_revocation_basepoint(byte[] val) {
204 bindings.AcceptChannelV2_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
205 Reference.reachabilityFence(this);
206 Reference.reachabilityFence(val);
210 * A payment key to channel acceptor for transactions broadcast by counterparty
212 public byte[] get_payment_basepoint() {
213 byte[] ret = bindings.AcceptChannelV2_get_payment_basepoint(this.ptr);
214 Reference.reachabilityFence(this);
219 * A payment key to channel acceptor for transactions broadcast by counterparty
221 public void set_payment_basepoint(byte[] val) {
222 bindings.AcceptChannelV2_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
223 Reference.reachabilityFence(this);
224 Reference.reachabilityFence(val);
228 * Used to derive a payment key to channel acceptor for transactions broadcast by channel
231 public byte[] get_delayed_payment_basepoint() {
232 byte[] ret = bindings.AcceptChannelV2_get_delayed_payment_basepoint(this.ptr);
233 Reference.reachabilityFence(this);
238 * Used to derive a payment key to channel acceptor for transactions broadcast by channel
241 public void set_delayed_payment_basepoint(byte[] val) {
242 bindings.AcceptChannelV2_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
243 Reference.reachabilityFence(this);
244 Reference.reachabilityFence(val);
248 * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
250 public byte[] get_htlc_basepoint() {
251 byte[] ret = bindings.AcceptChannelV2_get_htlc_basepoint(this.ptr);
252 Reference.reachabilityFence(this);
257 * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
259 public void set_htlc_basepoint(byte[] val) {
260 bindings.AcceptChannelV2_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
261 Reference.reachabilityFence(this);
262 Reference.reachabilityFence(val);
266 * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
268 public byte[] get_first_per_commitment_point() {
269 byte[] ret = bindings.AcceptChannelV2_get_first_per_commitment_point(this.ptr);
270 Reference.reachabilityFence(this);
275 * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
277 public void set_first_per_commitment_point(byte[] val) {
278 bindings.AcceptChannelV2_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
279 Reference.reachabilityFence(this);
280 Reference.reachabilityFence(val);
284 * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
286 public byte[] get_second_per_commitment_point() {
287 byte[] ret = bindings.AcceptChannelV2_get_second_per_commitment_point(this.ptr);
288 Reference.reachabilityFence(this);
293 * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
295 public void set_second_per_commitment_point(byte[] val) {
296 bindings.AcceptChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
297 Reference.reachabilityFence(this);
298 Reference.reachabilityFence(val);
302 * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
303 * collaboratively close
305 public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
306 long ret = bindings.AcceptChannelV2_get_shutdown_scriptpubkey(this.ptr);
307 Reference.reachabilityFence(this);
308 if (ret >= 0 && ret <= 4096) { return null; }
309 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
310 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
315 * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
316 * collaboratively close
318 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
319 bindings.AcceptChannelV2_set_shutdown_scriptpubkey(this.ptr, val.ptr);
320 Reference.reachabilityFence(this);
321 Reference.reachabilityFence(val);
322 if (this != null) { this.ptrs_to.add(val); };
326 * The channel type that this channel will represent. If none is set, we derive the channel
327 * type from the intersection of our feature bits with our counterparty's feature bits from
330 * This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
332 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
335 public ChannelTypeFeatures get_channel_type() {
336 long ret = bindings.AcceptChannelV2_get_channel_type(this.ptr);
337 Reference.reachabilityFence(this);
338 if (ret >= 0 && ret <= 4096) { return null; }
339 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
340 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
345 * The channel type that this channel will represent. If none is set, we derive the channel
346 * type from the intersection of our feature bits with our counterparty's feature bits from
349 * This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
351 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
353 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
354 bindings.AcceptChannelV2_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
355 Reference.reachabilityFence(this);
356 Reference.reachabilityFence(val);
357 if (this != null) { this.ptrs_to.add(val); };
361 * Optionally, a requirement that only confirmed inputs can be added
363 public COption_NoneZ get_require_confirmed_inputs() {
364 COption_NoneZ ret = bindings.AcceptChannelV2_get_require_confirmed_inputs(this.ptr);
365 Reference.reachabilityFence(this);
370 * Optionally, a requirement that only confirmed inputs can be added
372 public void set_require_confirmed_inputs(org.ldk.enums.COption_NoneZ val) {
373 bindings.AcceptChannelV2_set_require_confirmed_inputs(this.ptr, val);
374 Reference.reachabilityFence(this);
375 Reference.reachabilityFence(val);
379 * Constructs a new AcceptChannelV2 given each field
381 * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
383 public static AcceptChannelV2 of(byte[] temporary_channel_id_arg, long funding_satoshis_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, byte[] second_per_commitment_point_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg, org.ldk.enums.COption_NoneZ require_confirmed_inputs_arg) {
384 long ret = bindings.AcceptChannelV2_new(InternalUtils.check_arr_len(temporary_channel_id_arg, 32), funding_satoshis_arg, 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), InternalUtils.check_arr_len(second_per_commitment_point_arg, 33), shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr, require_confirmed_inputs_arg);
385 Reference.reachabilityFence(temporary_channel_id_arg);
386 Reference.reachabilityFence(funding_satoshis_arg);
387 Reference.reachabilityFence(dust_limit_satoshis_arg);
388 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
389 Reference.reachabilityFence(htlc_minimum_msat_arg);
390 Reference.reachabilityFence(minimum_depth_arg);
391 Reference.reachabilityFence(to_self_delay_arg);
392 Reference.reachabilityFence(max_accepted_htlcs_arg);
393 Reference.reachabilityFence(funding_pubkey_arg);
394 Reference.reachabilityFence(revocation_basepoint_arg);
395 Reference.reachabilityFence(payment_basepoint_arg);
396 Reference.reachabilityFence(delayed_payment_basepoint_arg);
397 Reference.reachabilityFence(htlc_basepoint_arg);
398 Reference.reachabilityFence(first_per_commitment_point_arg);
399 Reference.reachabilityFence(second_per_commitment_point_arg);
400 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
401 Reference.reachabilityFence(channel_type_arg);
402 Reference.reachabilityFence(require_confirmed_inputs_arg);
403 if (ret >= 0 && ret <= 4096) { return null; }
404 org.ldk.structs.AcceptChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannelV2(null, ret); }
405 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
406 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
407 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
412 long ret = bindings.AcceptChannelV2_clone_ptr(this.ptr);
413 Reference.reachabilityFence(this);
418 * Creates a copy of the AcceptChannelV2
420 public AcceptChannelV2 clone() {
421 long ret = bindings.AcceptChannelV2_clone(this.ptr);
422 Reference.reachabilityFence(this);
423 if (ret >= 0 && ret <= 4096) { return null; }
424 org.ldk.structs.AcceptChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannelV2(null, ret); }
425 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
430 * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
433 long ret = bindings.AcceptChannelV2_hash(this.ptr);
434 Reference.reachabilityFence(this);
438 @Override public int hashCode() {
439 return (int)this.hash();
442 * Checks if two AcceptChannelV2s contain equal inner contents.
443 * This ignores pointers and is_owned flags and looks at the values in fields.
444 * Two objects with NULL inner values will be considered "equal" here.
446 public boolean eq(org.ldk.structs.AcceptChannelV2 b) {
447 boolean ret = bindings.AcceptChannelV2_eq(this.ptr, b == null ? 0 : b.ptr);
448 Reference.reachabilityFence(this);
449 Reference.reachabilityFence(b);
450 if (this != null) { this.ptrs_to.add(b); };
454 @Override public boolean equals(Object o) {
455 if (!(o instanceof AcceptChannelV2)) return false;
456 return this.eq((AcceptChannelV2)o);
459 * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
461 public byte[] write() {
462 byte[] ret = bindings.AcceptChannelV2_write(this.ptr);
463 Reference.reachabilityFence(this);
468 * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
470 public static Result_AcceptChannelV2DecodeErrorZ read(byte[] ser) {
471 long ret = bindings.AcceptChannelV2_read(ser);
472 Reference.reachabilityFence(ser);
473 if (ret >= 0 && ret <= 4096) { return null; }
474 Result_AcceptChannelV2DecodeErrorZ ret_hu_conv = Result_AcceptChannelV2DecodeErrorZ.constr_from_ptr(ret);