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 or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class OpenChannel extends CommonBase {
16 OpenChannel(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
24 * The genesis hash of the blockchain where the channel is to be opened
26 public byte[] get_chain_hash() {
27 byte[] ret = bindings.OpenChannel_get_chain_hash(this.ptr);
28 Reference.reachabilityFence(this);
33 * The genesis hash of the blockchain where the channel is to be opened
35 public void set_chain_hash(byte[] val) {
36 bindings.OpenChannel_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * A temporary channel ID, until the funding outpoint is announced
44 public byte[] get_temporary_channel_id() {
45 byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
46 Reference.reachabilityFence(this);
51 * A temporary channel ID, until the funding outpoint is announced
53 public void set_temporary_channel_id(byte[] val) {
54 bindings.OpenChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
62 public long get_funding_satoshis() {
63 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
64 Reference.reachabilityFence(this);
71 public void set_funding_satoshis(long val) {
72 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
78 * The amount to push to the counterparty as part of the open, in milli-satoshi
80 public long get_push_msat() {
81 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
82 Reference.reachabilityFence(this);
87 * The amount to push to the counterparty as part of the open, in milli-satoshi
89 public void set_push_msat(long val) {
90 bindings.OpenChannel_set_push_msat(this.ptr, val);
91 Reference.reachabilityFence(this);
92 Reference.reachabilityFence(val);
96 * The threshold below which outputs on transactions broadcast by sender will be omitted
98 public long get_dust_limit_satoshis() {
99 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
100 Reference.reachabilityFence(this);
105 * The threshold below which outputs on transactions broadcast by sender will be omitted
107 public void set_dust_limit_satoshis(long val) {
108 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
109 Reference.reachabilityFence(this);
110 Reference.reachabilityFence(val);
114 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
116 public long get_max_htlc_value_in_flight_msat() {
117 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
118 Reference.reachabilityFence(this);
123 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
125 public void set_max_htlc_value_in_flight_msat(long val) {
126 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
127 Reference.reachabilityFence(this);
128 Reference.reachabilityFence(val);
132 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
134 public long get_channel_reserve_satoshis() {
135 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
136 Reference.reachabilityFence(this);
141 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
143 public void set_channel_reserve_satoshis(long val) {
144 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
145 Reference.reachabilityFence(this);
146 Reference.reachabilityFence(val);
150 * The minimum HTLC size incoming to sender, in milli-satoshi
152 public long get_htlc_minimum_msat() {
153 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
154 Reference.reachabilityFence(this);
159 * The minimum HTLC size incoming to sender, in milli-satoshi
161 public void set_htlc_minimum_msat(long val) {
162 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
163 Reference.reachabilityFence(this);
164 Reference.reachabilityFence(val);
168 * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
170 public int get_feerate_per_kw() {
171 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
172 Reference.reachabilityFence(this);
177 * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
179 public void set_feerate_per_kw(int val) {
180 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
181 Reference.reachabilityFence(this);
182 Reference.reachabilityFence(val);
186 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
188 public short get_to_self_delay() {
189 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
190 Reference.reachabilityFence(this);
195 * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
197 public void set_to_self_delay(short val) {
198 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
199 Reference.reachabilityFence(this);
200 Reference.reachabilityFence(val);
204 * The maximum number of inbound HTLCs towards sender
206 public short get_max_accepted_htlcs() {
207 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
208 Reference.reachabilityFence(this);
213 * The maximum number of inbound HTLCs towards sender
215 public void set_max_accepted_htlcs(short val) {
216 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
217 Reference.reachabilityFence(this);
218 Reference.reachabilityFence(val);
222 * The sender's key controlling the funding transaction
224 public byte[] get_funding_pubkey() {
225 byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
226 Reference.reachabilityFence(this);
231 * The sender's key controlling the funding transaction
233 public void set_funding_pubkey(byte[] val) {
234 bindings.OpenChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
235 Reference.reachabilityFence(this);
236 Reference.reachabilityFence(val);
240 * Used to derive a revocation key for transactions broadcast by counterparty
242 public byte[] get_revocation_basepoint() {
243 byte[] ret = bindings.OpenChannel_get_revocation_basepoint(this.ptr);
244 Reference.reachabilityFence(this);
249 * Used to derive a revocation key for transactions broadcast by counterparty
251 public void set_revocation_basepoint(byte[] val) {
252 bindings.OpenChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
253 Reference.reachabilityFence(this);
254 Reference.reachabilityFence(val);
258 * A payment key to sender for transactions broadcast by counterparty
260 public byte[] get_payment_point() {
261 byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr);
262 Reference.reachabilityFence(this);
267 * A payment key to sender for transactions broadcast by counterparty
269 public void set_payment_point(byte[] val) {
270 bindings.OpenChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
271 Reference.reachabilityFence(this);
272 Reference.reachabilityFence(val);
276 * Used to derive a payment key to sender for transactions broadcast by sender
278 public byte[] get_delayed_payment_basepoint() {
279 byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
280 Reference.reachabilityFence(this);
285 * Used to derive a payment key to sender for transactions broadcast by sender
287 public void set_delayed_payment_basepoint(byte[] val) {
288 bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
289 Reference.reachabilityFence(this);
290 Reference.reachabilityFence(val);
294 * Used to derive an HTLC payment key to sender
296 public byte[] get_htlc_basepoint() {
297 byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
298 Reference.reachabilityFence(this);
303 * Used to derive an HTLC payment key to sender
305 public void set_htlc_basepoint(byte[] val) {
306 bindings.OpenChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
307 Reference.reachabilityFence(this);
308 Reference.reachabilityFence(val);
312 * The first to-be-broadcast-by-sender transaction's per commitment point
314 public byte[] get_first_per_commitment_point() {
315 byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
316 Reference.reachabilityFence(this);
321 * The first to-be-broadcast-by-sender transaction's per commitment point
323 public void set_first_per_commitment_point(byte[] val) {
324 bindings.OpenChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
325 Reference.reachabilityFence(this);
326 Reference.reachabilityFence(val);
332 public byte get_channel_flags() {
333 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
334 Reference.reachabilityFence(this);
341 public void set_channel_flags(byte val) {
342 bindings.OpenChannel_set_channel_flags(this.ptr, val);
343 Reference.reachabilityFence(this);
344 Reference.reachabilityFence(val);
348 * The channel type that this channel will represent. If none is set, we derive the channel
349 * type from the intersection of our feature bits with our counterparty's feature bits from
352 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
355 public ChannelTypeFeatures get_channel_type() {
356 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
357 Reference.reachabilityFence(this);
358 if (ret >= 0 && ret <= 4096) { return null; }
359 ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTypeFeatures(null, ret); }
360 ret_hu_conv.ptrs_to.add(this);
365 * The channel type that this channel will represent. If none is set, we derive the channel
366 * type from the intersection of our feature bits with our counterparty's feature bits from
369 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
371 public void set_channel_type(@Nullable ChannelTypeFeatures val) {
372 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr & ~1);
373 Reference.reachabilityFence(this);
374 Reference.reachabilityFence(val);
378 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
379 Reference.reachabilityFence(this);
384 * Creates a copy of the OpenChannel
386 public OpenChannel clone() {
387 long ret = bindings.OpenChannel_clone(this.ptr);
388 Reference.reachabilityFence(this);
389 if (ret >= 0 && ret <= 4096) { return null; }
390 OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OpenChannel(null, ret); }
391 ret_hu_conv.ptrs_to.add(this);
396 * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
398 public byte[] write() {
399 byte[] ret = bindings.OpenChannel_write(this.ptr);
400 Reference.reachabilityFence(this);
405 * Read a OpenChannel from a byte array, created by OpenChannel_write
407 public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
408 long ret = bindings.OpenChannel_read(ser);
409 Reference.reachabilityFence(ser);
410 if (ret >= 0 && ret <= 4096) { return null; }
411 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);