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 * [`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 AcceptChannel extends CommonBase {
18 AcceptChannel(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
26 * A temporary channel ID, until the funding outpoint is announced
28 public byte[] get_temporary_channel_id() {
29 byte[] ret = bindings.AcceptChannel_get_temporary_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
35 * A temporary channel ID, until the funding outpoint is announced
37 public void set_temporary_channel_id(byte[] val) {
38 bindings.AcceptChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The threshold below which outputs on transactions broadcast by sender will be omitted
46 public long get_dust_limit_satoshis() {
47 long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this.ptr);
48 Reference.reachabilityFence(this);
53 * The threshold below which outputs on transactions broadcast by sender will be omitted
55 public void set_dust_limit_satoshis(long val) {
56 bindings.AcceptChannel_set_dust_limit_satoshis(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
64 public long get_max_htlc_value_in_flight_msat() {
65 long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this.ptr);
66 Reference.reachabilityFence(this);
71 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
73 public void set_max_htlc_value_in_flight_msat(long val) {
74 bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
82 public long get_channel_reserve_satoshis() {
83 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
84 Reference.reachabilityFence(this);
89 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
91 public void set_channel_reserve_satoshis(long val) {
92 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * The minimum HTLC size incoming to sender, in milli-satoshi
100 public long get_htlc_minimum_msat() {
101 long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this.ptr);
102 Reference.reachabilityFence(this);
107 * The minimum HTLC size incoming to sender, in milli-satoshi
109 public void set_htlc_minimum_msat(long val) {
110 bindings.AcceptChannel_set_htlc_minimum_msat(this.ptr, val);
111 Reference.reachabilityFence(this);
112 Reference.reachabilityFence(val);
116 * Minimum depth of the funding transaction before the channel is considered open
118 public int get_minimum_depth() {
119 int ret = bindings.AcceptChannel_get_minimum_depth(this.ptr);
120 Reference.reachabilityFence(this);
125 * Minimum depth of the funding transaction before the channel is considered open
127 public void set_minimum_depth(int val) {
128 bindings.AcceptChannel_set_minimum_depth(this.ptr, val);
129 Reference.reachabilityFence(this);
130 Reference.reachabilityFence(val);
134 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
136 public short get_to_self_delay() {
137 short ret = bindings.AcceptChannel_get_to_self_delay(this.ptr);
138 Reference.reachabilityFence(this);
143 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
145 public void set_to_self_delay(short val) {
146 bindings.AcceptChannel_set_to_self_delay(this.ptr, val);
147 Reference.reachabilityFence(this);
148 Reference.reachabilityFence(val);
152 * The maximum number of inbound HTLCs towards sender
154 public short get_max_accepted_htlcs() {
155 short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this.ptr);
156 Reference.reachabilityFence(this);
161 * The maximum number of inbound HTLCs towards sender
163 public void set_max_accepted_htlcs(short val) {
164 bindings.AcceptChannel_set_max_accepted_htlcs(this.ptr, val);
165 Reference.reachabilityFence(this);
166 Reference.reachabilityFence(val);
170 * The sender's key controlling the funding transaction
172 public byte[] get_funding_pubkey() {
173 byte[] ret = bindings.AcceptChannel_get_funding_pubkey(this.ptr);
174 Reference.reachabilityFence(this);
179 * The sender's key controlling the funding transaction
181 public void set_funding_pubkey(byte[] val) {
182 bindings.AcceptChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
183 Reference.reachabilityFence(this);
184 Reference.reachabilityFence(val);
188 * Used to derive a revocation key for transactions broadcast by counterparty
190 public byte[] get_revocation_basepoint() {
191 byte[] ret = bindings.AcceptChannel_get_revocation_basepoint(this.ptr);
192 Reference.reachabilityFence(this);
197 * Used to derive a revocation key for transactions broadcast by counterparty
199 public void set_revocation_basepoint(byte[] val) {
200 bindings.AcceptChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
201 Reference.reachabilityFence(this);
202 Reference.reachabilityFence(val);
206 * A payment key to sender for transactions broadcast by counterparty
208 public byte[] get_payment_point() {
209 byte[] ret = bindings.AcceptChannel_get_payment_point(this.ptr);
210 Reference.reachabilityFence(this);
215 * A payment key to sender for transactions broadcast by counterparty
217 public void set_payment_point(byte[] val) {
218 bindings.AcceptChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
219 Reference.reachabilityFence(this);
220 Reference.reachabilityFence(val);
224 * Used to derive a payment key to sender for transactions broadcast by sender
226 public byte[] get_delayed_payment_basepoint() {
227 byte[] ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this.ptr);
228 Reference.reachabilityFence(this);
233 * Used to derive a payment key to sender for transactions broadcast by sender
235 public void set_delayed_payment_basepoint(byte[] val) {
236 bindings.AcceptChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
237 Reference.reachabilityFence(this);
238 Reference.reachabilityFence(val);
242 * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
244 public byte[] get_htlc_basepoint() {
245 byte[] ret = bindings.AcceptChannel_get_htlc_basepoint(this.ptr);
246 Reference.reachabilityFence(this);
251 * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
253 public void set_htlc_basepoint(byte[] val) {
254 bindings.AcceptChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
255 Reference.reachabilityFence(this);
256 Reference.reachabilityFence(val);
260 * The first to-be-broadcast-by-sender transaction's per commitment point
262 public byte[] get_first_per_commitment_point() {
263 byte[] ret = bindings.AcceptChannel_get_first_per_commitment_point(this.ptr);
264 Reference.reachabilityFence(this);
269 * The first to-be-broadcast-by-sender transaction's per commitment point
271 public void set_first_per_commitment_point(byte[] val) {
272 bindings.AcceptChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
273 Reference.reachabilityFence(this);
274 Reference.reachabilityFence(val);
278 * The channel type that this channel will represent.
280 * If this is `None`, we derive the channel type from the intersection of
281 * our feature bits with our counterparty's feature bits from the [`Init`] message.
282 * This is required to match the equivalent field in [`OpenChannel::channel_type`].
284 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
287 public ChannelTypeFeatures get_channel_type() {
288 long ret = bindings.AcceptChannel_get_channel_type(this.ptr);
289 Reference.reachabilityFence(this);
290 if (ret >= 0 && ret <= 4096) { return null; }
291 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
292 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
297 * The channel type that this channel will represent.
299 * If this is `None`, we derive the channel type from the intersection of
300 * our feature bits with our counterparty's feature bits from the [`Init`] message.
301 * This is required to match the equivalent field in [`OpenChannel::channel_type`].
303 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
305 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
306 bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
307 Reference.reachabilityFence(this);
308 Reference.reachabilityFence(val);
309 if (this != null) { this.ptrs_to.add(val); };
313 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
314 Reference.reachabilityFence(this);
319 * Creates a copy of the AcceptChannel
321 public AcceptChannel clone() {
322 long ret = bindings.AcceptChannel_clone(this.ptr);
323 Reference.reachabilityFence(this);
324 if (ret >= 0 && ret <= 4096) { return null; }
325 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
326 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
331 * Checks if two AcceptChannels contain equal inner contents.
332 * This ignores pointers and is_owned flags and looks at the values in fields.
333 * Two objects with NULL inner values will be considered "equal" here.
335 public boolean eq(org.ldk.structs.AcceptChannel b) {
336 boolean ret = bindings.AcceptChannel_eq(this.ptr, b == null ? 0 : b.ptr);
337 Reference.reachabilityFence(this);
338 Reference.reachabilityFence(b);
339 if (this != null) { this.ptrs_to.add(b); };
343 @Override public boolean equals(Object o) {
344 if (!(o instanceof AcceptChannel)) return false;
345 return this.eq((AcceptChannel)o);
348 * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
350 public byte[] write() {
351 byte[] ret = bindings.AcceptChannel_write(this.ptr);
352 Reference.reachabilityFence(this);
357 * Read a AcceptChannel from a byte array, created by AcceptChannel_write
359 public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
360 long ret = bindings.AcceptChannel_read(ser);
361 Reference.reachabilityFence(ser);
362 if (ret >= 0 && ret <= 4096) { return null; }
363 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);