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_channel2 message to be sent by or received from the channel initiator.
14 * Used in V2 channel establishment
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class OpenChannelV2 extends CommonBase {
18 OpenChannelV2(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.OpenChannelV2_free(ptr); }
26 * Common fields of `open_channel(2)`-like messages
28 public CommonOpenChannelFields get_common_fields() {
29 long ret = bindings.OpenChannelV2_get_common_fields(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38 * Common fields of `open_channel(2)`-like messages
40 public void set_common_fields(org.ldk.structs.CommonOpenChannelFields val) {
41 bindings.OpenChannelV2_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 * The feerate for the funding transaction set by the channel initiator
50 public int get_funding_feerate_sat_per_1000_weight() {
51 int ret = bindings.OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this.ptr);
52 Reference.reachabilityFence(this);
57 * The feerate for the funding transaction set by the channel initiator
59 public void set_funding_feerate_sat_per_1000_weight(int val) {
60 bindings.OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * The locktime for the funding transaction
68 public int get_locktime() {
69 int ret = bindings.OpenChannelV2_get_locktime(this.ptr);
70 Reference.reachabilityFence(this);
75 * The locktime for the funding transaction
77 public void set_locktime(int val) {
78 bindings.OpenChannelV2_set_locktime(this.ptr, val);
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
86 public byte[] get_second_per_commitment_point() {
87 byte[] ret = bindings.OpenChannelV2_get_second_per_commitment_point(this.ptr);
88 Reference.reachabilityFence(this);
93 * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
95 public void set_second_per_commitment_point(byte[] val) {
96 bindings.OpenChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
97 Reference.reachabilityFence(this);
98 Reference.reachabilityFence(val);
102 * Optionally, a requirement that only confirmed inputs can be added
104 public COption_NoneZ get_require_confirmed_inputs() {
105 COption_NoneZ ret = bindings.OpenChannelV2_get_require_confirmed_inputs(this.ptr);
106 Reference.reachabilityFence(this);
111 * Optionally, a requirement that only confirmed inputs can be added
113 public void set_require_confirmed_inputs(org.ldk.enums.COption_NoneZ val) {
114 bindings.OpenChannelV2_set_require_confirmed_inputs(this.ptr, val);
115 Reference.reachabilityFence(this);
116 Reference.reachabilityFence(val);
120 * Constructs a new OpenChannelV2 given each field
122 public static OpenChannelV2 of(org.ldk.structs.CommonOpenChannelFields common_fields_arg, int funding_feerate_sat_per_1000_weight_arg, int locktime_arg, byte[] second_per_commitment_point_arg, org.ldk.enums.COption_NoneZ require_confirmed_inputs_arg) {
123 long ret = bindings.OpenChannelV2_new(common_fields_arg.ptr, funding_feerate_sat_per_1000_weight_arg, locktime_arg, InternalUtils.check_arr_len(second_per_commitment_point_arg, 33), require_confirmed_inputs_arg);
124 Reference.reachabilityFence(common_fields_arg);
125 Reference.reachabilityFence(funding_feerate_sat_per_1000_weight_arg);
126 Reference.reachabilityFence(locktime_arg);
127 Reference.reachabilityFence(second_per_commitment_point_arg);
128 Reference.reachabilityFence(require_confirmed_inputs_arg);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
132 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(common_fields_arg); };
137 long ret = bindings.OpenChannelV2_clone_ptr(this.ptr);
138 Reference.reachabilityFence(this);
143 * Creates a copy of the OpenChannelV2
145 public OpenChannelV2 clone() {
146 long ret = bindings.OpenChannelV2_clone(this.ptr);
147 Reference.reachabilityFence(this);
148 if (ret >= 0 && ret <= 4096) { return null; }
149 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
150 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
155 * Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
158 long ret = bindings.OpenChannelV2_hash(this.ptr);
159 Reference.reachabilityFence(this);
163 @Override public int hashCode() {
164 return (int)this.hash();
167 * Checks if two OpenChannelV2s contain equal inner contents.
168 * This ignores pointers and is_owned flags and looks at the values in fields.
169 * Two objects with NULL inner values will be considered "equal" here.
171 public boolean eq(org.ldk.structs.OpenChannelV2 b) {
172 boolean ret = bindings.OpenChannelV2_eq(this.ptr, b.ptr);
173 Reference.reachabilityFence(this);
174 Reference.reachabilityFence(b);
175 if (this != null) { this.ptrs_to.add(b); };
179 @Override public boolean equals(Object o) {
180 if (!(o instanceof OpenChannelV2)) return false;
181 return this.eq((OpenChannelV2)o);
184 * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
186 public byte[] write() {
187 byte[] ret = bindings.OpenChannelV2_write(this.ptr);
188 Reference.reachabilityFence(this);
193 * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
195 public static Result_OpenChannelV2DecodeErrorZ read(byte[] ser) {
196 long ret = bindings.OpenChannelV2_read(ser);
197 Reference.reachabilityFence(ser);
198 if (ret >= 0 && ret <= 4096) { return null; }
199 Result_OpenChannelV2DecodeErrorZ ret_hu_conv = Result_OpenChannelV2DecodeErrorZ.constr_from_ptr(ret);