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_channel2 message to be sent by or received from the channel accepter.
14 * Used in V2 channel establishment
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class AcceptChannelV2 extends CommonBase {
18 AcceptChannelV2(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.AcceptChannelV2_free(ptr); }
26 * Common fields of `accept_channel(2)`-like messages
28 public CommonAcceptChannelFields get_common_fields() {
29 long ret = bindings.AcceptChannelV2_get_common_fields(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.CommonAcceptChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonAcceptChannelFields(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38 * Common fields of `accept_channel(2)`-like messages
40 public void set_common_fields(org.ldk.structs.CommonAcceptChannelFields val) {
41 bindings.AcceptChannelV2_set_common_fields(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * Part of the channel value contributed by the channel acceptor
50 public long get_funding_satoshis() {
51 long ret = bindings.AcceptChannelV2_get_funding_satoshis(this.ptr);
52 Reference.reachabilityFence(this);
57 * Part of the channel value contributed by the channel acceptor
59 public void set_funding_satoshis(long val) {
60 bindings.AcceptChannelV2_set_funding_satoshis(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
68 public byte[] get_second_per_commitment_point() {
69 byte[] ret = bindings.AcceptChannelV2_get_second_per_commitment_point(this.ptr);
70 Reference.reachabilityFence(this);
75 * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
77 public void set_second_per_commitment_point(byte[] val) {
78 bindings.AcceptChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * Optionally, a requirement that only confirmed inputs can be added
86 public COption_NoneZ get_require_confirmed_inputs() {
87 COption_NoneZ ret = bindings.AcceptChannelV2_get_require_confirmed_inputs(this.ptr);
88 Reference.reachabilityFence(this);
93 * Optionally, a requirement that only confirmed inputs can be added
95 public void set_require_confirmed_inputs(org.ldk.enums.COption_NoneZ val) {
96 bindings.AcceptChannelV2_set_require_confirmed_inputs(this.ptr, val);
97 Reference.reachabilityFence(this);
98 Reference.reachabilityFence(val);
102 * Constructs a new AcceptChannelV2 given each field
104 public static AcceptChannelV2 of(org.ldk.structs.CommonAcceptChannelFields common_fields_arg, long funding_satoshis_arg, byte[] second_per_commitment_point_arg, org.ldk.enums.COption_NoneZ require_confirmed_inputs_arg) {
105 long ret = bindings.AcceptChannelV2_new(common_fields_arg.ptr, funding_satoshis_arg, InternalUtils.check_arr_len(second_per_commitment_point_arg, 33), require_confirmed_inputs_arg);
106 Reference.reachabilityFence(common_fields_arg);
107 Reference.reachabilityFence(funding_satoshis_arg);
108 Reference.reachabilityFence(second_per_commitment_point_arg);
109 Reference.reachabilityFence(require_confirmed_inputs_arg);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.AcceptChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannelV2(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(common_fields_arg); };
118 long ret = bindings.AcceptChannelV2_clone_ptr(this.ptr);
119 Reference.reachabilityFence(this);
124 * Creates a copy of the AcceptChannelV2
126 public AcceptChannelV2 clone() {
127 long ret = bindings.AcceptChannelV2_clone(this.ptr);
128 Reference.reachabilityFence(this);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.AcceptChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannelV2(null, ret); }
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
136 * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
139 long ret = bindings.AcceptChannelV2_hash(this.ptr);
140 Reference.reachabilityFence(this);
144 @Override public int hashCode() {
145 return (int)this.hash();
148 * Checks if two AcceptChannelV2s contain equal inner contents.
149 * This ignores pointers and is_owned flags and looks at the values in fields.
150 * Two objects with NULL inner values will be considered "equal" here.
152 public boolean eq(org.ldk.structs.AcceptChannelV2 b) {
153 boolean ret = bindings.AcceptChannelV2_eq(this.ptr, b.ptr);
154 Reference.reachabilityFence(this);
155 Reference.reachabilityFence(b);
156 if (this != null) { this.ptrs_to.add(b); };
160 @Override public boolean equals(Object o) {
161 if (!(o instanceof AcceptChannelV2)) return false;
162 return this.eq((AcceptChannelV2)o);
165 * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
167 public byte[] write() {
168 byte[] ret = bindings.AcceptChannelV2_write(this.ptr);
169 Reference.reachabilityFence(this);
174 * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
176 public static Result_AcceptChannelV2DecodeErrorZ read(byte[] ser) {
177 long ret = bindings.AcceptChannelV2_read(ser);
178 Reference.reachabilityFence(ser);
179 if (ret >= 0 && ret <= 4096) { return null; }
180 Result_AcceptChannelV2DecodeErrorZ ret_hu_conv = Result_AcceptChannelV2DecodeErrorZ.constr_from_ptr(ret);