Update auto-updated Java files
[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 or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ClosingSigned extends CommonBase {
16         ClosingSigned(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
21         }
22
23         /**
24          * The channel ID
25          */
26         public byte[] get_channel_id() {
27                 byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The channel ID
34          */
35         public void set_channel_id(byte[] val) {
36                 bindings.ClosingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The proposed total fee for the closing transaction
43          */
44         public long get_fee_satoshis() {
45                 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * The proposed total fee for the closing transaction
52          */
53         public void set_fee_satoshis(long val) {
54                 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * A signature on the closing transaction
61          */
62         public byte[] get_signature() {
63                 byte[] ret = bindings.ClosingSigned_get_signature(this.ptr);
64                 Reference.reachabilityFence(this);
65                 return ret;
66         }
67
68         /**
69          * A signature on the closing transaction
70          */
71         public void set_signature(byte[] val) {
72                 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
73                 Reference.reachabilityFence(this);
74                 Reference.reachabilityFence(val);
75         }
76
77         /**
78          * The minimum and maximum fees which the sender is willing to accept, provided only by new
79          * nodes.
80          * 
81          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
82          */
83         @Nullable
84         public ClosingSignedFeeRange get_fee_range() {
85                 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
86                 Reference.reachabilityFence(this);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSignedFeeRange(null, ret); }
89                 ret_hu_conv.ptrs_to.add(this);
90                 return ret_hu_conv;
91         }
92
93         /**
94          * The minimum and maximum fees which the sender is willing to accept, provided only by new
95          * nodes.
96          * 
97          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
98          */
99         public void set_fee_range(@Nullable ClosingSignedFeeRange val) {
100                 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr & ~1);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * Constructs a new ClosingSigned given each field
107          */
108         public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, ClosingSignedFeeRange fee_range_arg) {
109                 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 & ~1);
110                 Reference.reachabilityFence(channel_id_arg);
111                 Reference.reachabilityFence(fee_satoshis_arg);
112                 Reference.reachabilityFence(signature_arg);
113                 Reference.reachabilityFence(fee_range_arg);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSigned(null, ret); }
116                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
117                 return ret_hu_conv;
118         }
119
120         long clone_ptr() {
121                 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         /**
127          * Creates a copy of the ClosingSigned
128          */
129         public ClosingSigned clone() {
130                 long ret = bindings.ClosingSigned_clone(this.ptr);
131                 Reference.reachabilityFence(this);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSigned(null, ret); }
134                 ret_hu_conv.ptrs_to.add(this);
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
140          */
141         public byte[] write() {
142                 byte[] ret = bindings.ClosingSigned_write(this.ptr);
143                 Reference.reachabilityFence(this);
144                 return ret;
145         }
146
147         /**
148          * Read a ClosingSigned from a byte array, created by ClosingSigned_write
149          */
150         public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
151                 long ret = bindings.ClosingSigned_read(ser);
152                 Reference.reachabilityFence(ser);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
155                 return ret_hu_conv;
156         }
157
158 }