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_channel`] message to be sent to or received from a peer.
14 * Used in V1 channel establishment
16 * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class AcceptChannel extends CommonBase {
20 AcceptChannel(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
28 * A temporary channel ID, until the funding outpoint is announced
30 public byte[] get_temporary_channel_id() {
31 byte[] ret = bindings.AcceptChannel_get_temporary_channel_id(this.ptr);
32 Reference.reachabilityFence(this);
37 * A temporary channel ID, until the funding outpoint is announced
39 public void set_temporary_channel_id(byte[] val) {
40 bindings.AcceptChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
46 * The threshold below which outputs on transactions broadcast by sender will be omitted
48 public long get_dust_limit_satoshis() {
49 long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this.ptr);
50 Reference.reachabilityFence(this);
55 * The threshold below which outputs on transactions broadcast by sender will be omitted
57 public void set_dust_limit_satoshis(long val) {
58 bindings.AcceptChannel_set_dust_limit_satoshis(this.ptr, val);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
64 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
66 public long get_max_htlc_value_in_flight_msat() {
67 long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this.ptr);
68 Reference.reachabilityFence(this);
73 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
75 public void set_max_htlc_value_in_flight_msat(long val) {
76 bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
77 Reference.reachabilityFence(this);
78 Reference.reachabilityFence(val);
82 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
84 public long get_channel_reserve_satoshis() {
85 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
86 Reference.reachabilityFence(this);
91 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
93 public void set_channel_reserve_satoshis(long val) {
94 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
95 Reference.reachabilityFence(this);
96 Reference.reachabilityFence(val);
100 * The minimum HTLC size incoming to sender, in milli-satoshi
102 public long get_htlc_minimum_msat() {
103 long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this.ptr);
104 Reference.reachabilityFence(this);
109 * The minimum HTLC size incoming to sender, in milli-satoshi
111 public void set_htlc_minimum_msat(long val) {
112 bindings.AcceptChannel_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.AcceptChannel_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.AcceptChannel_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 broadcast a commitment transaction
138 public short get_to_self_delay() {
139 short ret = bindings.AcceptChannel_get_to_self_delay(this.ptr);
140 Reference.reachabilityFence(this);
145 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
147 public void set_to_self_delay(short val) {
148 bindings.AcceptChannel_set_to_self_delay(this.ptr, val);
149 Reference.reachabilityFence(this);
150 Reference.reachabilityFence(val);
154 * The maximum number of inbound HTLCs towards sender
156 public short get_max_accepted_htlcs() {
157 short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this.ptr);
158 Reference.reachabilityFence(this);
163 * The maximum number of inbound HTLCs towards sender
165 public void set_max_accepted_htlcs(short val) {
166 bindings.AcceptChannel_set_max_accepted_htlcs(this.ptr, val);
167 Reference.reachabilityFence(this);
168 Reference.reachabilityFence(val);
172 * The sender's key controlling the funding transaction
174 public byte[] get_funding_pubkey() {
175 byte[] ret = bindings.AcceptChannel_get_funding_pubkey(this.ptr);
176 Reference.reachabilityFence(this);
181 * The sender's key controlling the funding transaction
183 public void set_funding_pubkey(byte[] val) {
184 bindings.AcceptChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
185 Reference.reachabilityFence(this);
186 Reference.reachabilityFence(val);
190 * Used to derive a revocation key for transactions broadcast by counterparty
192 public byte[] get_revocation_basepoint() {
193 byte[] ret = bindings.AcceptChannel_get_revocation_basepoint(this.ptr);
194 Reference.reachabilityFence(this);
199 * Used to derive a revocation key for transactions broadcast by counterparty
201 public void set_revocation_basepoint(byte[] val) {
202 bindings.AcceptChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
203 Reference.reachabilityFence(this);
204 Reference.reachabilityFence(val);
208 * A payment key to sender for transactions broadcast by counterparty
210 public byte[] get_payment_point() {
211 byte[] ret = bindings.AcceptChannel_get_payment_point(this.ptr);
212 Reference.reachabilityFence(this);
217 * A payment key to sender for transactions broadcast by counterparty
219 public void set_payment_point(byte[] val) {
220 bindings.AcceptChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
221 Reference.reachabilityFence(this);
222 Reference.reachabilityFence(val);
226 * Used to derive a payment key to sender for transactions broadcast by sender
228 public byte[] get_delayed_payment_basepoint() {
229 byte[] ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this.ptr);
230 Reference.reachabilityFence(this);
235 * Used to derive a payment key to sender for transactions broadcast by sender
237 public void set_delayed_payment_basepoint(byte[] val) {
238 bindings.AcceptChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
239 Reference.reachabilityFence(this);
240 Reference.reachabilityFence(val);
244 * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
246 public byte[] get_htlc_basepoint() {
247 byte[] ret = bindings.AcceptChannel_get_htlc_basepoint(this.ptr);
248 Reference.reachabilityFence(this);
253 * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
255 public void set_htlc_basepoint(byte[] val) {
256 bindings.AcceptChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
257 Reference.reachabilityFence(this);
258 Reference.reachabilityFence(val);
262 * The first to-be-broadcast-by-sender transaction's per commitment point
264 public byte[] get_first_per_commitment_point() {
265 byte[] ret = bindings.AcceptChannel_get_first_per_commitment_point(this.ptr);
266 Reference.reachabilityFence(this);
271 * The first to-be-broadcast-by-sender transaction's per commitment point
273 public void set_first_per_commitment_point(byte[] val) {
274 bindings.AcceptChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
275 Reference.reachabilityFence(this);
276 Reference.reachabilityFence(val);
280 * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
282 public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
283 long ret = bindings.AcceptChannel_get_shutdown_scriptpubkey(this.ptr);
284 Reference.reachabilityFence(this);
285 if (ret >= 0 && ret <= 4096) { return null; }
286 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
287 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
292 * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
294 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
295 bindings.AcceptChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
296 Reference.reachabilityFence(this);
297 Reference.reachabilityFence(val);
298 if (this != null) { this.ptrs_to.add(val); };
302 * The channel type that this channel will represent.
304 * If this is `None`, we derive the channel type from the intersection of
305 * our feature bits with our counterparty's feature bits from the [`Init`] message.
306 * This is required to match the equivalent field in [`OpenChannel::channel_type`].
308 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
311 public ChannelTypeFeatures get_channel_type() {
312 long ret = bindings.AcceptChannel_get_channel_type(this.ptr);
313 Reference.reachabilityFence(this);
314 if (ret >= 0 && ret <= 4096) { return null; }
315 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
316 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
321 * The channel type that this channel will represent.
323 * If this is `None`, we derive the channel type from the intersection of
324 * our feature bits with our counterparty's feature bits from the [`Init`] message.
325 * This is required to match the equivalent field in [`OpenChannel::channel_type`].
327 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
329 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
330 bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
331 Reference.reachabilityFence(this);
332 Reference.reachabilityFence(val);
333 if (this != null) { this.ptrs_to.add(val); };
337 * Constructs a new AcceptChannel given each field
339 * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
341 public static AcceptChannel of(byte[] temporary_channel_id_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long channel_reserve_satoshis_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_point_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) {
342 long ret = bindings.AcceptChannel_new(InternalUtils.check_arr_len(temporary_channel_id_arg, 32), dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_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_point_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);
343 Reference.reachabilityFence(temporary_channel_id_arg);
344 Reference.reachabilityFence(dust_limit_satoshis_arg);
345 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
346 Reference.reachabilityFence(channel_reserve_satoshis_arg);
347 Reference.reachabilityFence(htlc_minimum_msat_arg);
348 Reference.reachabilityFence(minimum_depth_arg);
349 Reference.reachabilityFence(to_self_delay_arg);
350 Reference.reachabilityFence(max_accepted_htlcs_arg);
351 Reference.reachabilityFence(funding_pubkey_arg);
352 Reference.reachabilityFence(revocation_basepoint_arg);
353 Reference.reachabilityFence(payment_point_arg);
354 Reference.reachabilityFence(delayed_payment_basepoint_arg);
355 Reference.reachabilityFence(htlc_basepoint_arg);
356 Reference.reachabilityFence(first_per_commitment_point_arg);
357 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
358 Reference.reachabilityFence(channel_type_arg);
359 if (ret >= 0 && ret <= 4096) { return null; }
360 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
361 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
362 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
363 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
368 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
369 Reference.reachabilityFence(this);
374 * Creates a copy of the AcceptChannel
376 public AcceptChannel clone() {
377 long ret = bindings.AcceptChannel_clone(this.ptr);
378 Reference.reachabilityFence(this);
379 if (ret >= 0 && ret <= 4096) { return null; }
380 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
381 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
386 * Checks if two AcceptChannels contain equal inner contents.
387 * This ignores pointers and is_owned flags and looks at the values in fields.
388 * Two objects with NULL inner values will be considered "equal" here.
390 public boolean eq(org.ldk.structs.AcceptChannel b) {
391 boolean ret = bindings.AcceptChannel_eq(this.ptr, b == null ? 0 : b.ptr);
392 Reference.reachabilityFence(this);
393 Reference.reachabilityFence(b);
394 if (this != null) { this.ptrs_to.add(b); };
398 @Override public boolean equals(Object o) {
399 if (!(o instanceof AcceptChannel)) return false;
400 return this.eq((AcceptChannel)o);
403 * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
405 public byte[] write() {
406 byte[] ret = bindings.AcceptChannel_write(this.ptr);
407 Reference.reachabilityFence(this);
412 * Read a AcceptChannel from a byte array, created by AcceptChannel_write
414 public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
415 long ret = bindings.AcceptChannel_read(ser);
416 Reference.reachabilityFence(ser);
417 if (ret >= 0 && ret <= 4096) { return null; }
418 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);