[Java] Update auto-generated Java bindings
[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         public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
112                 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);
113                 Reference.reachabilityFence(channel_id_arg);
114                 Reference.reachabilityFence(fee_satoshis_arg);
115                 Reference.reachabilityFence(signature_arg);
116                 Reference.reachabilityFence(fee_range_arg);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_range_arg); };
121                 return ret_hu_conv;
122         }
123
124         long clone_ptr() {
125                 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
126                 Reference.reachabilityFence(this);
127                 return ret;
128         }
129
130         /**
131          * Creates a copy of the ClosingSigned
132          */
133         public ClosingSigned clone() {
134                 long ret = bindings.ClosingSigned_clone(this.ptr);
135                 Reference.reachabilityFence(this);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
138                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
139                 return ret_hu_conv;
140         }
141
142         /**
143          * Checks if two ClosingSigneds contain equal inner contents.
144          * This ignores pointers and is_owned flags and looks at the values in fields.
145          * Two objects with NULL inner values will be considered "equal" here.
146          */
147         public boolean eq(org.ldk.structs.ClosingSigned b) {
148                 boolean ret = bindings.ClosingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(b);
151                 if (this != null) { this.ptrs_to.add(b); };
152                 return ret;
153         }
154
155         @Override public boolean equals(Object o) {
156                 if (!(o instanceof ClosingSigned)) return false;
157                 return this.eq((ClosingSigned)o);
158         }
159         /**
160          * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
161          */
162         public byte[] write() {
163                 byte[] ret = bindings.ClosingSigned_write(this.ptr);
164                 Reference.reachabilityFence(this);
165                 return ret;
166         }
167
168         /**
169          * Read a ClosingSigned from a byte array, created by ClosingSigned_write
170          */
171         public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
172                 long ret = bindings.ClosingSigned_read(ser);
173                 Reference.reachabilityFence(ser);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
176                 return ret_hu_conv;
177         }
178
179 }