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 open_channel2 message to be sent by or received from the channel initiator.
14 * Used in V2 channel establishment
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class OpenChannelV2 extends CommonBase {
18 OpenChannelV2(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.OpenChannelV2_free(ptr); }
26 * The genesis hash of the blockchain where the channel is to be opened
28 public byte[] get_chain_hash() {
29 byte[] ret = bindings.OpenChannelV2_get_chain_hash(this.ptr);
30 Reference.reachabilityFence(this);
35 * The genesis hash of the blockchain where the channel is to be opened
37 public void set_chain_hash(byte[] val) {
38 bindings.OpenChannelV2_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
46 public byte[] get_temporary_channel_id() {
47 byte[] ret = bindings.OpenChannelV2_get_temporary_channel_id(this.ptr);
48 Reference.reachabilityFence(this);
53 * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
55 public void set_temporary_channel_id(byte[] val) {
56 bindings.OpenChannelV2_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The feerate for the funding transaction set by the channel initiator
64 public int get_funding_feerate_sat_per_1000_weight() {
65 int ret = bindings.OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this.ptr);
66 Reference.reachabilityFence(this);
71 * The feerate for the funding transaction set by the channel initiator
73 public void set_funding_feerate_sat_per_1000_weight(int val) {
74 bindings.OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The feerate for the commitment transaction set by the channel initiator
82 public int get_commitment_feerate_sat_per_1000_weight() {
83 int ret = bindings.OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this.ptr);
84 Reference.reachabilityFence(this);
89 * The feerate for the commitment transaction set by the channel initiator
91 public void set_commitment_feerate_sat_per_1000_weight(int val) {
92 bindings.OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * Part of the channel value contributed by the channel initiator
100 public long get_funding_satoshis() {
101 long ret = bindings.OpenChannelV2_get_funding_satoshis(this.ptr);
102 Reference.reachabilityFence(this);
107 * Part of the channel value contributed by the channel initiator
109 public void set_funding_satoshis(long val) {
110 bindings.OpenChannelV2_set_funding_satoshis(this.ptr, val);
111 Reference.reachabilityFence(this);
112 Reference.reachabilityFence(val);
116 * The threshold below which outputs on transactions broadcast by the channel initiator will be
119 public long get_dust_limit_satoshis() {
120 long ret = bindings.OpenChannelV2_get_dust_limit_satoshis(this.ptr);
121 Reference.reachabilityFence(this);
126 * The threshold below which outputs on transactions broadcast by the channel initiator will be
129 public void set_dust_limit_satoshis(long val) {
130 bindings.OpenChannelV2_set_dust_limit_satoshis(this.ptr, val);
131 Reference.reachabilityFence(this);
132 Reference.reachabilityFence(val);
136 * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
138 public long get_max_htlc_value_in_flight_msat() {
139 long ret = bindings.OpenChannelV2_get_max_htlc_value_in_flight_msat(this.ptr);
140 Reference.reachabilityFence(this);
145 * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
147 public void set_max_htlc_value_in_flight_msat(long val) {
148 bindings.OpenChannelV2_set_max_htlc_value_in_flight_msat(this.ptr, val);
149 Reference.reachabilityFence(this);
150 Reference.reachabilityFence(val);
154 * The minimum HTLC size incoming to channel initiator, in milli-satoshi
156 public long get_htlc_minimum_msat() {
157 long ret = bindings.OpenChannelV2_get_htlc_minimum_msat(this.ptr);
158 Reference.reachabilityFence(this);
163 * The minimum HTLC size incoming to channel initiator, in milli-satoshi
165 public void set_htlc_minimum_msat(long val) {
166 bindings.OpenChannelV2_set_htlc_minimum_msat(this.ptr, val);
167 Reference.reachabilityFence(this);
168 Reference.reachabilityFence(val);
172 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
173 * broadcast a commitment transaction
175 public short get_to_self_delay() {
176 short ret = bindings.OpenChannelV2_get_to_self_delay(this.ptr);
177 Reference.reachabilityFence(this);
182 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
183 * broadcast a commitment transaction
185 public void set_to_self_delay(short val) {
186 bindings.OpenChannelV2_set_to_self_delay(this.ptr, val);
187 Reference.reachabilityFence(this);
188 Reference.reachabilityFence(val);
192 * The maximum number of inbound HTLCs towards channel initiator
194 public short get_max_accepted_htlcs() {
195 short ret = bindings.OpenChannelV2_get_max_accepted_htlcs(this.ptr);
196 Reference.reachabilityFence(this);
201 * The maximum number of inbound HTLCs towards channel initiator
203 public void set_max_accepted_htlcs(short val) {
204 bindings.OpenChannelV2_set_max_accepted_htlcs(this.ptr, val);
205 Reference.reachabilityFence(this);
206 Reference.reachabilityFence(val);
210 * The locktime for the funding transaction
212 public int get_locktime() {
213 int ret = bindings.OpenChannelV2_get_locktime(this.ptr);
214 Reference.reachabilityFence(this);
219 * The locktime for the funding transaction
221 public void set_locktime(int val) {
222 bindings.OpenChannelV2_set_locktime(this.ptr, val);
223 Reference.reachabilityFence(this);
224 Reference.reachabilityFence(val);
228 * The channel initiator's key controlling the funding transaction
230 public byte[] get_funding_pubkey() {
231 byte[] ret = bindings.OpenChannelV2_get_funding_pubkey(this.ptr);
232 Reference.reachabilityFence(this);
237 * The channel initiator's key controlling the funding transaction
239 public void set_funding_pubkey(byte[] val) {
240 bindings.OpenChannelV2_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
241 Reference.reachabilityFence(this);
242 Reference.reachabilityFence(val);
246 * Used to derive a revocation key for transactions broadcast by counterparty
248 public byte[] get_revocation_basepoint() {
249 byte[] ret = bindings.OpenChannelV2_get_revocation_basepoint(this.ptr);
250 Reference.reachabilityFence(this);
255 * Used to derive a revocation key for transactions broadcast by counterparty
257 public void set_revocation_basepoint(byte[] val) {
258 bindings.OpenChannelV2_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
259 Reference.reachabilityFence(this);
260 Reference.reachabilityFence(val);
264 * A payment key to channel initiator for transactions broadcast by counterparty
266 public byte[] get_payment_basepoint() {
267 byte[] ret = bindings.OpenChannelV2_get_payment_basepoint(this.ptr);
268 Reference.reachabilityFence(this);
273 * A payment key to channel initiator for transactions broadcast by counterparty
275 public void set_payment_basepoint(byte[] val) {
276 bindings.OpenChannelV2_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
277 Reference.reachabilityFence(this);
278 Reference.reachabilityFence(val);
282 * Used to derive a payment key to channel initiator for transactions broadcast by channel
285 public byte[] get_delayed_payment_basepoint() {
286 byte[] ret = bindings.OpenChannelV2_get_delayed_payment_basepoint(this.ptr);
287 Reference.reachabilityFence(this);
292 * Used to derive a payment key to channel initiator for transactions broadcast by channel
295 public void set_delayed_payment_basepoint(byte[] val) {
296 bindings.OpenChannelV2_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
297 Reference.reachabilityFence(this);
298 Reference.reachabilityFence(val);
302 * Used to derive an HTLC payment key to channel initiator
304 public byte[] get_htlc_basepoint() {
305 byte[] ret = bindings.OpenChannelV2_get_htlc_basepoint(this.ptr);
306 Reference.reachabilityFence(this);
311 * Used to derive an HTLC payment key to channel initiator
313 public void set_htlc_basepoint(byte[] val) {
314 bindings.OpenChannelV2_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
315 Reference.reachabilityFence(this);
316 Reference.reachabilityFence(val);
320 * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
322 public byte[] get_first_per_commitment_point() {
323 byte[] ret = bindings.OpenChannelV2_get_first_per_commitment_point(this.ptr);
324 Reference.reachabilityFence(this);
329 * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
331 public void set_first_per_commitment_point(byte[] val) {
332 bindings.OpenChannelV2_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
333 Reference.reachabilityFence(this);
334 Reference.reachabilityFence(val);
338 * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
340 public byte[] get_second_per_commitment_point() {
341 byte[] ret = bindings.OpenChannelV2_get_second_per_commitment_point(this.ptr);
342 Reference.reachabilityFence(this);
347 * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
349 public void set_second_per_commitment_point(byte[] val) {
350 bindings.OpenChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
351 Reference.reachabilityFence(this);
352 Reference.reachabilityFence(val);
358 public byte get_channel_flags() {
359 byte ret = bindings.OpenChannelV2_get_channel_flags(this.ptr);
360 Reference.reachabilityFence(this);
367 public void set_channel_flags(byte val) {
368 bindings.OpenChannelV2_set_channel_flags(this.ptr, val);
369 Reference.reachabilityFence(this);
370 Reference.reachabilityFence(val);
374 * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
375 * collaboratively close
377 public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
378 long ret = bindings.OpenChannelV2_get_shutdown_scriptpubkey(this.ptr);
379 Reference.reachabilityFence(this);
380 if (ret >= 0 && ret <= 4096) { return null; }
381 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
382 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
387 * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
388 * collaboratively close
390 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
391 bindings.OpenChannelV2_set_shutdown_scriptpubkey(this.ptr, val.ptr);
392 Reference.reachabilityFence(this);
393 Reference.reachabilityFence(val);
394 if (this != null) { this.ptrs_to.add(val); };
398 * The channel type that this channel will represent. If none is set, we derive the channel
399 * type from the intersection of our feature bits with our counterparty's feature bits from
402 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
405 public ChannelTypeFeatures get_channel_type() {
406 long ret = bindings.OpenChannelV2_get_channel_type(this.ptr);
407 Reference.reachabilityFence(this);
408 if (ret >= 0 && ret <= 4096) { return null; }
409 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
410 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
415 * The channel type that this channel will represent. If none is set, we derive the channel
416 * type from the intersection of our feature bits with our counterparty's feature bits from
419 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
421 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
422 bindings.OpenChannelV2_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
423 Reference.reachabilityFence(this);
424 Reference.reachabilityFence(val);
425 if (this != null) { this.ptrs_to.add(val); };
429 * Optionally, a requirement that only confirmed inputs can be added
431 public COption_NoneZ get_require_confirmed_inputs() {
432 COption_NoneZ ret = bindings.OpenChannelV2_get_require_confirmed_inputs(this.ptr);
433 Reference.reachabilityFence(this);
438 * Optionally, a requirement that only confirmed inputs can be added
440 public void set_require_confirmed_inputs(org.ldk.enums.COption_NoneZ val) {
441 bindings.OpenChannelV2_set_require_confirmed_inputs(this.ptr, val);
442 Reference.reachabilityFence(this);
443 Reference.reachabilityFence(val);
447 * Constructs a new OpenChannelV2 given each field
449 * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
451 public static OpenChannelV2 of(byte[] chain_hash_arg, byte[] temporary_channel_id_arg, int funding_feerate_sat_per_1000_weight_arg, int commitment_feerate_sat_per_1000_weight_arg, long funding_satoshis_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long htlc_minimum_msat_arg, short to_self_delay_arg, short max_accepted_htlcs_arg, int locktime_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, byte channel_flags_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) {
452 long ret = bindings.OpenChannelV2_new(InternalUtils.check_arr_len(chain_hash_arg, 32), InternalUtils.check_arr_len(temporary_channel_id_arg, 32), funding_feerate_sat_per_1000_weight_arg, commitment_feerate_sat_per_1000_weight_arg, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, to_self_delay_arg, max_accepted_htlcs_arg, locktime_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), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr, require_confirmed_inputs_arg);
453 Reference.reachabilityFence(chain_hash_arg);
454 Reference.reachabilityFence(temporary_channel_id_arg);
455 Reference.reachabilityFence(funding_feerate_sat_per_1000_weight_arg);
456 Reference.reachabilityFence(commitment_feerate_sat_per_1000_weight_arg);
457 Reference.reachabilityFence(funding_satoshis_arg);
458 Reference.reachabilityFence(dust_limit_satoshis_arg);
459 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
460 Reference.reachabilityFence(htlc_minimum_msat_arg);
461 Reference.reachabilityFence(to_self_delay_arg);
462 Reference.reachabilityFence(max_accepted_htlcs_arg);
463 Reference.reachabilityFence(locktime_arg);
464 Reference.reachabilityFence(funding_pubkey_arg);
465 Reference.reachabilityFence(revocation_basepoint_arg);
466 Reference.reachabilityFence(payment_basepoint_arg);
467 Reference.reachabilityFence(delayed_payment_basepoint_arg);
468 Reference.reachabilityFence(htlc_basepoint_arg);
469 Reference.reachabilityFence(first_per_commitment_point_arg);
470 Reference.reachabilityFence(second_per_commitment_point_arg);
471 Reference.reachabilityFence(channel_flags_arg);
472 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
473 Reference.reachabilityFence(channel_type_arg);
474 Reference.reachabilityFence(require_confirmed_inputs_arg);
475 if (ret >= 0 && ret <= 4096) { return null; }
476 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
477 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
478 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
479 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
484 long ret = bindings.OpenChannelV2_clone_ptr(this.ptr);
485 Reference.reachabilityFence(this);
490 * Creates a copy of the OpenChannelV2
492 public OpenChannelV2 clone() {
493 long ret = bindings.OpenChannelV2_clone(this.ptr);
494 Reference.reachabilityFence(this);
495 if (ret >= 0 && ret <= 4096) { return null; }
496 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
497 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
502 * Checks if two OpenChannelV2s contain equal inner contents.
503 * This ignores pointers and is_owned flags and looks at the values in fields.
504 * Two objects with NULL inner values will be considered "equal" here.
506 public boolean eq(org.ldk.structs.OpenChannelV2 b) {
507 boolean ret = bindings.OpenChannelV2_eq(this.ptr, b == null ? 0 : b.ptr);
508 Reference.reachabilityFence(this);
509 Reference.reachabilityFence(b);
510 if (this != null) { this.ptrs_to.add(b); };
514 @Override public boolean equals(Object o) {
515 if (!(o instanceof OpenChannelV2)) return false;
516 return this.eq((OpenChannelV2)o);
519 * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
521 public byte[] write() {
522 byte[] ret = bindings.OpenChannelV2_write(this.ptr);
523 Reference.reachabilityFence(this);
528 * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
530 public static Result_OpenChannelV2DecodeErrorZ read(byte[] ser) {
531 long ret = bindings.OpenChannelV2_read(ser);
532 Reference.reachabilityFence(ser);
533 if (ret >= 0 && ret <= 4096) { return null; }
534 Result_OpenChannelV2DecodeErrorZ ret_hu_conv = Result_OpenChannelV2DecodeErrorZ.constr_from_ptr(ret);