[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / RevokeAndACK.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 [`revoke_and_ack`] message to be sent to or received from a peer.
13  * 
14  * [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class RevokeAndACK extends CommonBase {
18         RevokeAndACK(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.RevokeAndACK_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public byte[] get_channel_id() {
29                 byte[] ret = bindings.RevokeAndACK_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.RevokeAndACK_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The secret corresponding to the per-commitment point
45          */
46         public byte[] get_per_commitment_secret() {
47                 byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The secret corresponding to the per-commitment point
54          */
55         public void set_per_commitment_secret(byte[] val) {
56                 bindings.RevokeAndACK_set_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * The next sender-broadcast commitment transaction's per-commitment point
63          */
64         public byte[] get_next_per_commitment_point() {
65                 byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The next sender-broadcast commitment transaction's per-commitment point
72          */
73         public void set_next_per_commitment_point(byte[] val) {
74                 bindings.RevokeAndACK_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * Constructs a new RevokeAndACK given each field
81          */
82         public static RevokeAndACK of(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) {
83                 long ret = bindings.RevokeAndACK_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(per_commitment_secret_arg, 32), InternalUtils.check_arr_len(next_per_commitment_point_arg, 33));
84                 Reference.reachabilityFence(channel_id_arg);
85                 Reference.reachabilityFence(per_commitment_secret_arg);
86                 Reference.reachabilityFence(next_per_commitment_point_arg);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
90                 return ret_hu_conv;
91         }
92
93         long clone_ptr() {
94                 long ret = bindings.RevokeAndACK_clone_ptr(this.ptr);
95                 Reference.reachabilityFence(this);
96                 return ret;
97         }
98
99         /**
100          * Creates a copy of the RevokeAndACK
101          */
102         public RevokeAndACK clone() {
103                 long ret = bindings.RevokeAndACK_clone(this.ptr);
104                 Reference.reachabilityFence(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
113          */
114         public long hash() {
115                 long ret = bindings.RevokeAndACK_hash(this.ptr);
116                 Reference.reachabilityFence(this);
117                 return ret;
118         }
119
120         @Override public int hashCode() {
121                 return (int)this.hash();
122         }
123         /**
124          * Checks if two RevokeAndACKs contain equal inner contents.
125          * This ignores pointers and is_owned flags and looks at the values in fields.
126          * Two objects with NULL inner values will be considered "equal" here.
127          */
128         public boolean eq(org.ldk.structs.RevokeAndACK b) {
129                 boolean ret = bindings.RevokeAndACK_eq(this.ptr, b == null ? 0 : b.ptr);
130                 Reference.reachabilityFence(this);
131                 Reference.reachabilityFence(b);
132                 if (this != null) { this.ptrs_to.add(b); };
133                 return ret;
134         }
135
136         @Override public boolean equals(Object o) {
137                 if (!(o instanceof RevokeAndACK)) return false;
138                 return this.eq((RevokeAndACK)o);
139         }
140         /**
141          * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
142          */
143         public byte[] write() {
144                 byte[] ret = bindings.RevokeAndACK_write(this.ptr);
145                 Reference.reachabilityFence(this);
146                 return ret;
147         }
148
149         /**
150          * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
151          */
152         public static Result_RevokeAndACKDecodeErrorZ read(byte[] ser) {
153                 long ret = bindings.RevokeAndACK_read(ser);
154                 Reference.reachabilityFence(ser);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
157                 return ret_hu_conv;
158         }
159
160 }