[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ClosingSigned.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  * A [`closing_signed`] message to be sent to or received from a peer.
13  * 
14  * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ClosingSigned extends CommonBase {
18         ClosingSigned(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The channel ID
36          */
37         public void set_channel_id(byte[] val) {
38                 bindings.ClosingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The proposed total fee for the closing transaction
45          */
46         public long get_fee_satoshis() {
47                 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The proposed total fee for the closing transaction
54          */
55         public void set_fee_satoshis(long val) {
56                 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * A signature on the closing transaction
63          */
64         public byte[] get_signature() {
65                 byte[] ret = bindings.ClosingSigned_get_signature(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * A signature on the closing transaction
72          */
73         public void set_signature(byte[] val) {
74                 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The minimum and maximum fees which the sender is willing to accept, provided only by new
81          * nodes.
82          * 
83          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
84          */
85         @Nullable
86         public ClosingSignedFeeRange get_fee_range() {
87                 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
88                 Reference.reachabilityFence(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * The minimum and maximum fees which the sender is willing to accept, provided only by new
97          * nodes.
98          * 
99          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
100          */
101         public void set_fee_range(@Nullable org.ldk.structs.ClosingSignedFeeRange val) {
102                 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105                 if (this != null) { this.ptrs_to.add(val); };
106         }
107
108         /**
109          * Constructs a new ClosingSigned given each field
110          * 
111          * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
112          */
113         public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, @Nullable org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
114                 long ret = bindings.ClosingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), fee_satoshis_arg, InternalUtils.check_arr_len(signature_arg, 64), fee_range_arg == null ? 0 : fee_range_arg.ptr);
115                 Reference.reachabilityFence(channel_id_arg);
116                 Reference.reachabilityFence(fee_satoshis_arg);
117                 Reference.reachabilityFence(signature_arg);
118                 Reference.reachabilityFence(fee_range_arg);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_range_arg); };
123                 return ret_hu_conv;
124         }
125
126         long clone_ptr() {
127                 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * Creates a copy of the ClosingSigned
134          */
135         public ClosingSigned clone() {
136                 long ret = bindings.ClosingSigned_clone(this.ptr);
137                 Reference.reachabilityFence(this);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
140                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
141                 return ret_hu_conv;
142         }
143
144         /**
145          * Generates a non-cryptographic 64-bit hash of the ClosingSigned.
146          */
147         public long hash() {
148                 long ret = bindings.ClosingSigned_hash(this.ptr);
149                 Reference.reachabilityFence(this);
150                 return ret;
151         }
152
153         @Override public int hashCode() {
154                 return (int)this.hash();
155         }
156         /**
157          * Checks if two ClosingSigneds contain equal inner contents.
158          * This ignores pointers and is_owned flags and looks at the values in fields.
159          * Two objects with NULL inner values will be considered "equal" here.
160          */
161         public boolean eq(org.ldk.structs.ClosingSigned b) {
162                 boolean ret = bindings.ClosingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
163                 Reference.reachabilityFence(this);
164                 Reference.reachabilityFence(b);
165                 if (this != null) { this.ptrs_to.add(b); };
166                 return ret;
167         }
168
169         @Override public boolean equals(Object o) {
170                 if (!(o instanceof ClosingSigned)) return false;
171                 return this.eq((ClosingSigned)o);
172         }
173         /**
174          * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
175          */
176         public byte[] write() {
177                 byte[] ret = bindings.ClosingSigned_write(this.ptr);
178                 Reference.reachabilityFence(this);
179                 return ret;
180         }
181
182         /**
183          * Read a ClosingSigned from a byte array, created by ClosingSigned_write
184          */
185         public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
186                 long ret = bindings.ClosingSigned_read(ser);
187                 Reference.reachabilityFence(ser);
188                 if (ret >= 0 && ret <= 4096) { return null; }
189                 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
190                 return ret_hu_conv;
191         }
192
193 }