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_channel`] message to be sent to or received from a peer.
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 OpenChannel extends CommonBase {
18 OpenChannel(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.OpenChannel_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.OpenChannel_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.OpenChannel_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * A temporary channel ID, until the funding outpoint is announced
46 public byte[] get_temporary_channel_id() {
47 byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
48 Reference.reachabilityFence(this);
53 * A temporary channel ID, until the funding outpoint is announced
55 public void set_temporary_channel_id(byte[] val) {
56 bindings.OpenChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
64 public long get_funding_satoshis() {
65 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
66 Reference.reachabilityFence(this);
73 public void set_funding_satoshis(long val) {
74 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The amount to push to the counterparty as part of the open, in milli-satoshi
82 public long get_push_msat() {
83 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
84 Reference.reachabilityFence(this);
89 * The amount to push to the counterparty as part of the open, in milli-satoshi
91 public void set_push_msat(long val) {
92 bindings.OpenChannel_set_push_msat(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * The threshold below which outputs on transactions broadcast by sender will be omitted
100 public long get_dust_limit_satoshis() {
101 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
102 Reference.reachabilityFence(this);
107 * The threshold below which outputs on transactions broadcast by sender will be omitted
109 public void set_dust_limit_satoshis(long val) {
110 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
111 Reference.reachabilityFence(this);
112 Reference.reachabilityFence(val);
116 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
118 public long get_max_htlc_value_in_flight_msat() {
119 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
120 Reference.reachabilityFence(this);
125 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
127 public void set_max_htlc_value_in_flight_msat(long val) {
128 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
129 Reference.reachabilityFence(this);
130 Reference.reachabilityFence(val);
134 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
136 public long get_channel_reserve_satoshis() {
137 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
138 Reference.reachabilityFence(this);
143 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
145 public void set_channel_reserve_satoshis(long val) {
146 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
147 Reference.reachabilityFence(this);
148 Reference.reachabilityFence(val);
152 * The minimum HTLC size incoming to sender, in milli-satoshi
154 public long get_htlc_minimum_msat() {
155 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
156 Reference.reachabilityFence(this);
161 * The minimum HTLC size incoming to sender, in milli-satoshi
163 public void set_htlc_minimum_msat(long val) {
164 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
165 Reference.reachabilityFence(this);
166 Reference.reachabilityFence(val);
170 * The feerate per 1000-weight of sender generated transactions, until updated by
173 public int get_feerate_per_kw() {
174 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
175 Reference.reachabilityFence(this);
180 * The feerate per 1000-weight of sender generated transactions, until updated by
183 public void set_feerate_per_kw(int val) {
184 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
185 Reference.reachabilityFence(this);
186 Reference.reachabilityFence(val);
190 * The number of blocks which the counterparty will have to wait to claim on-chain funds if
191 * they broadcast a commitment transaction
193 public short get_to_self_delay() {
194 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
195 Reference.reachabilityFence(this);
200 * The number of blocks which the counterparty will have to wait to claim on-chain funds if
201 * they broadcast a commitment transaction
203 public void set_to_self_delay(short val) {
204 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
205 Reference.reachabilityFence(this);
206 Reference.reachabilityFence(val);
210 * The maximum number of inbound HTLCs towards sender
212 public short get_max_accepted_htlcs() {
213 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
214 Reference.reachabilityFence(this);
219 * The maximum number of inbound HTLCs towards sender
221 public void set_max_accepted_htlcs(short val) {
222 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
223 Reference.reachabilityFence(this);
224 Reference.reachabilityFence(val);
228 * The sender's key controlling the funding transaction
230 public byte[] get_funding_pubkey() {
231 byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
232 Reference.reachabilityFence(this);
237 * The sender's key controlling the funding transaction
239 public void set_funding_pubkey(byte[] val) {
240 bindings.OpenChannel_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.OpenChannel_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.OpenChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
259 Reference.reachabilityFence(this);
260 Reference.reachabilityFence(val);
264 * A payment key to sender for transactions broadcast by counterparty
266 public byte[] get_payment_point() {
267 byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr);
268 Reference.reachabilityFence(this);
273 * A payment key to sender for transactions broadcast by counterparty
275 public void set_payment_point(byte[] val) {
276 bindings.OpenChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
277 Reference.reachabilityFence(this);
278 Reference.reachabilityFence(val);
282 * Used to derive a payment key to sender for transactions broadcast by sender
284 public byte[] get_delayed_payment_basepoint() {
285 byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
286 Reference.reachabilityFence(this);
291 * Used to derive a payment key to sender for transactions broadcast by sender
293 public void set_delayed_payment_basepoint(byte[] val) {
294 bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
295 Reference.reachabilityFence(this);
296 Reference.reachabilityFence(val);
300 * Used to derive an HTLC payment key to sender
302 public byte[] get_htlc_basepoint() {
303 byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
304 Reference.reachabilityFence(this);
309 * Used to derive an HTLC payment key to sender
311 public void set_htlc_basepoint(byte[] val) {
312 bindings.OpenChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
313 Reference.reachabilityFence(this);
314 Reference.reachabilityFence(val);
318 * The first to-be-broadcast-by-sender transaction's per commitment point
320 public byte[] get_first_per_commitment_point() {
321 byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
322 Reference.reachabilityFence(this);
327 * The first to-be-broadcast-by-sender transaction's per commitment point
329 public void set_first_per_commitment_point(byte[] val) {
330 bindings.OpenChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
331 Reference.reachabilityFence(this);
332 Reference.reachabilityFence(val);
336 * The channel flags to be used
338 public byte get_channel_flags() {
339 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
340 Reference.reachabilityFence(this);
345 * The channel flags to be used
347 public void set_channel_flags(byte val) {
348 bindings.OpenChannel_set_channel_flags(this.ptr, val);
349 Reference.reachabilityFence(this);
350 Reference.reachabilityFence(val);
354 * The channel type that this channel will represent
356 * If this is `None`, we derive the channel type from the intersection of our
357 * feature bits with our counterparty's feature bits from the [`Init`] message.
359 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
362 public ChannelTypeFeatures get_channel_type() {
363 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
364 Reference.reachabilityFence(this);
365 if (ret >= 0 && ret <= 4096) { return null; }
366 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
367 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
372 * The channel type that this channel will represent
374 * If this is `None`, we derive the channel type from the intersection of our
375 * feature bits with our counterparty's feature bits from the [`Init`] message.
377 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
379 public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
380 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
381 Reference.reachabilityFence(this);
382 Reference.reachabilityFence(val);
383 if (this != null) { this.ptrs_to.add(val); };
387 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
388 Reference.reachabilityFence(this);
393 * Creates a copy of the OpenChannel
395 public OpenChannel clone() {
396 long ret = bindings.OpenChannel_clone(this.ptr);
397 Reference.reachabilityFence(this);
398 if (ret >= 0 && ret <= 4096) { return null; }
399 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
400 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
405 * Checks if two OpenChannels contain equal inner contents.
406 * This ignores pointers and is_owned flags and looks at the values in fields.
407 * Two objects with NULL inner values will be considered "equal" here.
409 public boolean eq(org.ldk.structs.OpenChannel b) {
410 boolean ret = bindings.OpenChannel_eq(this.ptr, b == null ? 0 : b.ptr);
411 Reference.reachabilityFence(this);
412 Reference.reachabilityFence(b);
413 if (this != null) { this.ptrs_to.add(b); };
417 @Override public boolean equals(Object o) {
418 if (!(o instanceof OpenChannel)) return false;
419 return this.eq((OpenChannel)o);
422 * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
424 public byte[] write() {
425 byte[] ret = bindings.OpenChannel_write(this.ptr);
426 Reference.reachabilityFence(this);
431 * Read a OpenChannel from a byte array, created by OpenChannel_write
433 public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
434 long ret = bindings.OpenChannel_read(ser);
435 Reference.reachabilityFence(ser);
436 if (ret >= 0 && ret <= 4096) { return null; }
437 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);