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