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 [`open_channel`] and `open_channel2` messages.
14 * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class CommonOpenChannelFields extends CommonBase {
18 CommonOpenChannelFields(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.CommonOpenChannelFields_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.CommonOpenChannelFields_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.CommonOpenChannelFields_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * A temporary channel ID
45 * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
46 * For V1 channels: a temporary channel ID, until the funding outpoint is announced
48 public ChannelId get_temporary_channel_id() {
49 long ret = bindings.CommonOpenChannelFields_get_temporary_channel_id(this.ptr);
50 Reference.reachabilityFence(this);
51 if (ret >= 0 && ret <= 4096) { return null; }
52 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
53 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
58 * A temporary channel ID
59 * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
60 * For V1 channels: a temporary channel ID, until the funding outpoint is announced
62 public void set_temporary_channel_id(org.ldk.structs.ChannelId val) {
63 bindings.CommonOpenChannelFields_set_temporary_channel_id(this.ptr, val.ptr);
64 Reference.reachabilityFence(this);
65 Reference.reachabilityFence(val);
66 if (this != null) { this.ptrs_to.add(val); };
70 * For V1 channels: The channel value
71 * For V2 channels: Part of the channel value contributed by the channel initiator
73 public long get_funding_satoshis() {
74 long ret = bindings.CommonOpenChannelFields_get_funding_satoshis(this.ptr);
75 Reference.reachabilityFence(this);
80 * For V1 channels: The channel value
81 * For V2 channels: Part of the channel value contributed by the channel initiator
83 public void set_funding_satoshis(long val) {
84 bindings.CommonOpenChannelFields_set_funding_satoshis(this.ptr, val);
85 Reference.reachabilityFence(this);
86 Reference.reachabilityFence(val);
90 * The threshold below which outputs on transactions broadcast by the channel initiator will be
93 public long get_dust_limit_satoshis() {
94 long ret = bindings.CommonOpenChannelFields_get_dust_limit_satoshis(this.ptr);
95 Reference.reachabilityFence(this);
100 * The threshold below which outputs on transactions broadcast by the channel initiator will be
103 public void set_dust_limit_satoshis(long val) {
104 bindings.CommonOpenChannelFields_set_dust_limit_satoshis(this.ptr, val);
105 Reference.reachabilityFence(this);
106 Reference.reachabilityFence(val);
110 * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
112 public long get_max_htlc_value_in_flight_msat() {
113 long ret = bindings.CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this.ptr);
114 Reference.reachabilityFence(this);
119 * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
121 public void set_max_htlc_value_in_flight_msat(long val) {
122 bindings.CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this.ptr, val);
123 Reference.reachabilityFence(this);
124 Reference.reachabilityFence(val);
128 * The minimum HTLC size incoming to channel initiator, in milli-satoshi
130 public long get_htlc_minimum_msat() {
131 long ret = bindings.CommonOpenChannelFields_get_htlc_minimum_msat(this.ptr);
132 Reference.reachabilityFence(this);
137 * The minimum HTLC size incoming to channel initiator, in milli-satoshi
139 public void set_htlc_minimum_msat(long val) {
140 bindings.CommonOpenChannelFields_set_htlc_minimum_msat(this.ptr, val);
141 Reference.reachabilityFence(this);
142 Reference.reachabilityFence(val);
146 * The feerate for the commitment transaction set by the channel initiator until updated by
149 public int get_commitment_feerate_sat_per_1000_weight() {
150 int ret = bindings.CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this.ptr);
151 Reference.reachabilityFence(this);
156 * The feerate for the commitment transaction set by the channel initiator until updated by
159 public void set_commitment_feerate_sat_per_1000_weight(int val) {
160 bindings.CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this.ptr, val);
161 Reference.reachabilityFence(this);
162 Reference.reachabilityFence(val);
166 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
167 * broadcast a commitment transaction
169 public short get_to_self_delay() {
170 short ret = bindings.CommonOpenChannelFields_get_to_self_delay(this.ptr);
171 Reference.reachabilityFence(this);
176 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
177 * broadcast a commitment transaction
179 public void set_to_self_delay(short val) {
180 bindings.CommonOpenChannelFields_set_to_self_delay(this.ptr, val);
181 Reference.reachabilityFence(this);
182 Reference.reachabilityFence(val);
186 * The maximum number of inbound HTLCs towards channel initiator
188 public short get_max_accepted_htlcs() {
189 short ret = bindings.CommonOpenChannelFields_get_max_accepted_htlcs(this.ptr);
190 Reference.reachabilityFence(this);
195 * The maximum number of inbound HTLCs towards channel initiator
197 public void set_max_accepted_htlcs(short val) {
198 bindings.CommonOpenChannelFields_set_max_accepted_htlcs(this.ptr, val);
199 Reference.reachabilityFence(this);
200 Reference.reachabilityFence(val);
204 * The channel initiator's key controlling the funding transaction
206 public byte[] get_funding_pubkey() {
207 byte[] ret = bindings.CommonOpenChannelFields_get_funding_pubkey(this.ptr);
208 Reference.reachabilityFence(this);
213 * The channel initiator's key controlling the funding transaction
215 public void set_funding_pubkey(byte[] val) {
216 bindings.CommonOpenChannelFields_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
217 Reference.reachabilityFence(this);
218 Reference.reachabilityFence(val);
222 * Used to derive a revocation key for transactions broadcast by counterparty
224 public byte[] get_revocation_basepoint() {
225 byte[] ret = bindings.CommonOpenChannelFields_get_revocation_basepoint(this.ptr);
226 Reference.reachabilityFence(this);
231 * Used to derive a revocation key for transactions broadcast by counterparty
233 public void set_revocation_basepoint(byte[] val) {
234 bindings.CommonOpenChannelFields_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
235 Reference.reachabilityFence(this);
236 Reference.reachabilityFence(val);
240 * A payment key to channel initiator for transactions broadcast by counterparty
242 public byte[] get_payment_basepoint() {
243 byte[] ret = bindings.CommonOpenChannelFields_get_payment_basepoint(this.ptr);
244 Reference.reachabilityFence(this);
249 * A payment key to channel initiator for transactions broadcast by counterparty
251 public void set_payment_basepoint(byte[] val) {
252 bindings.CommonOpenChannelFields_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
253 Reference.reachabilityFence(this);
254 Reference.reachabilityFence(val);
258 * Used to derive a payment key to channel initiator for transactions broadcast by channel
261 public byte[] get_delayed_payment_basepoint() {
262 byte[] ret = bindings.CommonOpenChannelFields_get_delayed_payment_basepoint(this.ptr);
263 Reference.reachabilityFence(this);
268 * Used to derive a payment key to channel initiator for transactions broadcast by channel
271 public void set_delayed_payment_basepoint(byte[] val) {
272 bindings.CommonOpenChannelFields_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
273 Reference.reachabilityFence(this);
274 Reference.reachabilityFence(val);
278 * Used to derive an HTLC payment key to channel initiator
280 public byte[] get_htlc_basepoint() {
281 byte[] ret = bindings.CommonOpenChannelFields_get_htlc_basepoint(this.ptr);
282 Reference.reachabilityFence(this);
287 * Used to derive an HTLC payment key to channel initiator
289 public void set_htlc_basepoint(byte[] val) {
290 bindings.CommonOpenChannelFields_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
291 Reference.reachabilityFence(this);
292 Reference.reachabilityFence(val);
296 * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
298 public byte[] get_first_per_commitment_point() {
299 byte[] ret = bindings.CommonOpenChannelFields_get_first_per_commitment_point(this.ptr);
300 Reference.reachabilityFence(this);
305 * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
307 public void set_first_per_commitment_point(byte[] val) {
308 bindings.CommonOpenChannelFields_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
309 Reference.reachabilityFence(this);
310 Reference.reachabilityFence(val);
314 * The channel flags to be used
316 public byte get_channel_flags() {
317 byte ret = bindings.CommonOpenChannelFields_get_channel_flags(this.ptr);
318 Reference.reachabilityFence(this);
323 * The channel flags to be used
325 public void set_channel_flags(byte val) {
326 bindings.CommonOpenChannelFields_set_channel_flags(this.ptr, val);
327 Reference.reachabilityFence(this);
328 Reference.reachabilityFence(val);
332 * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
333 * collaboratively close
335 public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
336 long ret = bindings.CommonOpenChannelFields_get_shutdown_scriptpubkey(this.ptr);
337 Reference.reachabilityFence(this);
338 if (ret >= 0 && ret <= 4096) { return null; }
339 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
340 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
345 * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
346 * collaboratively close
348 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
349 bindings.CommonOpenChannelFields_set_shutdown_scriptpubkey(this.ptr, val.ptr);
350 Reference.reachabilityFence(this);
351 Reference.reachabilityFence(val);
352 if (this != null) { this.ptrs_to.add(val); };
356 * The channel type that this channel will represent
358 * If this is `None`, we derive the channel type from the intersection of our
359 * feature bits with our counterparty's feature bits from the [`Init`] message.
361 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
364 public ChannelTypeFeatures get_channel_type() {
365 long ret = bindings.CommonOpenChannelFields_get_channel_type(this.ptr);
366 Reference.reachabilityFence(this);
367 if (ret >= 0 && ret <= 4096) { return null; }
368 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
369 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
374 * The channel type that this channel will represent
376 * If this is `None`, we derive the channel type from the intersection of our
377 * feature bits with our counterparty's feature bits from the [`Init`] message.
379 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
381 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
382 bindings.CommonOpenChannelFields_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
383 Reference.reachabilityFence(this);
384 Reference.reachabilityFence(val);
385 if (this != null) { this.ptrs_to.add(val); };
389 * Constructs a new CommonOpenChannelFields given each field
391 * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
393 public static CommonOpenChannelFields of(byte[] chain_hash_arg, org.ldk.structs.ChannelId 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 commitment_feerate_sat_per_1000_weight_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 channel_flags_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
394 long ret = bindings.CommonOpenChannelFields_new(InternalUtils.check_arr_len(chain_hash_arg, 32), temporary_channel_id_arg.ptr, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, commitment_feerate_sat_per_1000_weight_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), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
395 Reference.reachabilityFence(chain_hash_arg);
396 Reference.reachabilityFence(temporary_channel_id_arg);
397 Reference.reachabilityFence(funding_satoshis_arg);
398 Reference.reachabilityFence(dust_limit_satoshis_arg);
399 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
400 Reference.reachabilityFence(htlc_minimum_msat_arg);
401 Reference.reachabilityFence(commitment_feerate_sat_per_1000_weight_arg);
402 Reference.reachabilityFence(to_self_delay_arg);
403 Reference.reachabilityFence(max_accepted_htlcs_arg);
404 Reference.reachabilityFence(funding_pubkey_arg);
405 Reference.reachabilityFence(revocation_basepoint_arg);
406 Reference.reachabilityFence(payment_basepoint_arg);
407 Reference.reachabilityFence(delayed_payment_basepoint_arg);
408 Reference.reachabilityFence(htlc_basepoint_arg);
409 Reference.reachabilityFence(first_per_commitment_point_arg);
410 Reference.reachabilityFence(channel_flags_arg);
411 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
412 Reference.reachabilityFence(channel_type_arg);
413 if (ret >= 0 && ret <= 4096) { return null; }
414 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
415 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
416 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(temporary_channel_id_arg); };
417 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
418 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
423 long ret = bindings.CommonOpenChannelFields_clone_ptr(this.ptr);
424 Reference.reachabilityFence(this);
429 * Creates a copy of the CommonOpenChannelFields
431 public CommonOpenChannelFields clone() {
432 long ret = bindings.CommonOpenChannelFields_clone(this.ptr);
433 Reference.reachabilityFence(this);
434 if (ret >= 0 && ret <= 4096) { return null; }
435 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
436 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
441 * Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields.
444 long ret = bindings.CommonOpenChannelFields_hash(this.ptr);
445 Reference.reachabilityFence(this);
449 @Override public int hashCode() {
450 return (int)this.hash();
453 * Checks if two CommonOpenChannelFieldss contain equal inner contents.
454 * This ignores pointers and is_owned flags and looks at the values in fields.
455 * Two objects with NULL inner values will be considered "equal" here.
457 public boolean eq(org.ldk.structs.CommonOpenChannelFields b) {
458 boolean ret = bindings.CommonOpenChannelFields_eq(this.ptr, b.ptr);
459 Reference.reachabilityFence(this);
460 Reference.reachabilityFence(b);
461 if (this != null) { this.ptrs_to.add(b); };
465 @Override public boolean equals(Object o) {
466 if (!(o instanceof CommonOpenChannelFields)) return false;
467 return this.eq((CommonOpenChannelFields)o);