[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / main / java / org / ldk / structs / AcceptChannelV2.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 accept_channel2 message to be sent by or received from the channel accepter.
13  * 
14  * Used in V2 channel establishment
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.AcceptChannelV2_free(ptr); }
23         }
24
25         /**
26          * Common fields of `accept_channel(2)`-like messages
27          */
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); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Common fields of `accept_channel(2)`-like messages
39          */
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); };
45         }
46
47         /**
48          * Part of the channel value contributed by the channel acceptor
49          */
50         public long get_funding_satoshis() {
51                 long ret = bindings.AcceptChannelV2_get_funding_satoshis(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * Part of the channel value contributed by the channel acceptor
58          */
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);
63         }
64
65         /**
66          * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
67          */
68         public byte[] get_second_per_commitment_point() {
69                 byte[] ret = bindings.AcceptChannelV2_get_second_per_commitment_point(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
76          */
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);
81         }
82
83         /**
84          * Optionally, a requirement that only confirmed inputs can be added
85          */
86         public COption_NoneZ get_require_confirmed_inputs() {
87                 COption_NoneZ ret = bindings.AcceptChannelV2_get_require_confirmed_inputs(this.ptr);
88                 Reference.reachabilityFence(this);
89                 return ret;
90         }
91
92         /**
93          * Optionally, a requirement that only confirmed inputs can be added
94          */
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);
99         }
100
101         /**
102          * Constructs a new AcceptChannelV2 given each field
103          */
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); };
114                 return ret_hu_conv;
115         }
116
117         long clone_ptr() {
118                 long ret = bindings.AcceptChannelV2_clone_ptr(this.ptr);
119                 Reference.reachabilityFence(this);
120                 return ret;
121         }
122
123         /**
124          * Creates a copy of the AcceptChannelV2
125          */
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); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
137          */
138         public long hash() {
139                 long ret = bindings.AcceptChannelV2_hash(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         @Override public int hashCode() {
145                 return (int)this.hash();
146         }
147         /**
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.
151          */
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); };
157                 return ret;
158         }
159
160         @Override public boolean equals(Object o) {
161                 if (!(o instanceof AcceptChannelV2)) return false;
162                 return this.eq((AcceptChannelV2)o);
163         }
164         /**
165          * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
166          */
167         public byte[] write() {
168                 byte[] ret = bindings.AcceptChannelV2_write(this.ptr);
169                 Reference.reachabilityFence(this);
170                 return ret;
171         }
172
173         /**
174          * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
175          */
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);
181                 return ret_hu_conv;
182         }
183
184 }