[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / main / java / org / ldk / structs / OpenChannelV2.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An open_channel2 message to be sent by or received from the channel initiator.
13  * 
14  * Used in V2 channel establishment
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.OpenChannelV2_free(ptr); }
23         }
24
25         /**
26          * Common fields of `open_channel(2)`-like messages
27          */
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); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Common fields of `open_channel(2)`-like messages
39          */
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); };
45         }
46
47         /**
48          * The feerate for the funding transaction set by the channel initiator
49          */
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);
53                 return ret;
54         }
55
56         /**
57          * The feerate for the funding transaction set by the channel initiator
58          */
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);
63         }
64
65         /**
66          * The locktime for the funding transaction
67          */
68         public int get_locktime() {
69                 int ret = bindings.OpenChannelV2_get_locktime(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * The locktime for the funding transaction
76          */
77         public void set_locktime(int val) {
78                 bindings.OpenChannelV2_set_locktime(this.ptr, val);
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(val);
81         }
82
83         /**
84          * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
85          */
86         public byte[] get_second_per_commitment_point() {
87                 byte[] ret = bindings.OpenChannelV2_get_second_per_commitment_point(this.ptr);
88                 Reference.reachabilityFence(this);
89                 return ret;
90         }
91
92         /**
93          * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
94          */
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);
99         }
100
101         /**
102          * Optionally, a requirement that only confirmed inputs can be added
103          */
104         public COption_NoneZ get_require_confirmed_inputs() {
105                 COption_NoneZ ret = bindings.OpenChannelV2_get_require_confirmed_inputs(this.ptr);
106                 Reference.reachabilityFence(this);
107                 return ret;
108         }
109
110         /**
111          * Optionally, a requirement that only confirmed inputs can be added
112          */
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);
117         }
118
119         /**
120          * Constructs a new OpenChannelV2 given each field
121          */
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); };
133                 return ret_hu_conv;
134         }
135
136         long clone_ptr() {
137                 long ret = bindings.OpenChannelV2_clone_ptr(this.ptr);
138                 Reference.reachabilityFence(this);
139                 return ret;
140         }
141
142         /**
143          * Creates a copy of the OpenChannelV2
144          */
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); };
151                 return ret_hu_conv;
152         }
153
154         /**
155          * Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
156          */
157         public long hash() {
158                 long ret = bindings.OpenChannelV2_hash(this.ptr);
159                 Reference.reachabilityFence(this);
160                 return ret;
161         }
162
163         @Override public int hashCode() {
164                 return (int)this.hash();
165         }
166         /**
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.
170          */
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); };
176                 return ret;
177         }
178
179         @Override public boolean equals(Object o) {
180                 if (!(o instanceof OpenChannelV2)) return false;
181                 return this.eq((OpenChannelV2)o);
182         }
183         /**
184          * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
185          */
186         public byte[] write() {
187                 byte[] ret = bindings.OpenChannelV2_write(this.ptr);
188                 Reference.reachabilityFence(this);
189                 return ret;
190         }
191
192         /**
193          * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
194          */
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);
200                 return ret_hu_conv;
201         }
202
203 }