[C#] Run tests against release library in determinism CI run
[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 ChannelId get_channel_id() {
29                 long ret = bindings.RevokeAndACK_get_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * The channel ID
39          */
40         public void set_channel_id(org.ldk.structs.ChannelId val) {
41                 bindings.RevokeAndACK_set_channel_id(this.ptr, val.ptr);
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44                 if (this != null) { this.ptrs_to.add(val); };
45         }
46
47         /**
48          * The secret corresponding to the per-commitment point
49          */
50         public byte[] get_per_commitment_secret() {
51                 byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * The secret corresponding to the per-commitment point
58          */
59         public void set_per_commitment_secret(byte[] val) {
60                 bindings.RevokeAndACK_set_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * The next sender-broadcast commitment transaction's per-commitment point
67          */
68         public byte[] get_next_per_commitment_point() {
69                 byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * The next sender-broadcast commitment transaction's per-commitment point
76          */
77         public void set_next_per_commitment_point(byte[] val) {
78                 bindings.RevokeAndACK_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(val);
81         }
82
83         /**
84          * Constructs a new RevokeAndACK given each field
85          */
86         public static RevokeAndACK of(org.ldk.structs.ChannelId channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) {
87                 long ret = bindings.RevokeAndACK_new(channel_id_arg.ptr, InternalUtils.check_arr_len(per_commitment_secret_arg, 32), InternalUtils.check_arr_len(next_per_commitment_point_arg, 33));
88                 Reference.reachabilityFence(channel_id_arg);
89                 Reference.reachabilityFence(per_commitment_secret_arg);
90                 Reference.reachabilityFence(next_per_commitment_point_arg);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
95                 return ret_hu_conv;
96         }
97
98         long clone_ptr() {
99                 long ret = bindings.RevokeAndACK_clone_ptr(this.ptr);
100                 Reference.reachabilityFence(this);
101                 return ret;
102         }
103
104         /**
105          * Creates a copy of the RevokeAndACK
106          */
107         public RevokeAndACK clone() {
108                 long ret = bindings.RevokeAndACK_clone(this.ptr);
109                 Reference.reachabilityFence(this);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
113                 return ret_hu_conv;
114         }
115
116         /**
117          * Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
118          */
119         public long hash() {
120                 long ret = bindings.RevokeAndACK_hash(this.ptr);
121                 Reference.reachabilityFence(this);
122                 return ret;
123         }
124
125         @Override public int hashCode() {
126                 return (int)this.hash();
127         }
128         /**
129          * Checks if two RevokeAndACKs contain equal inner contents.
130          * This ignores pointers and is_owned flags and looks at the values in fields.
131          * Two objects with NULL inner values will be considered "equal" here.
132          */
133         public boolean eq(org.ldk.structs.RevokeAndACK b) {
134                 boolean ret = bindings.RevokeAndACK_eq(this.ptr, b.ptr);
135                 Reference.reachabilityFence(this);
136                 Reference.reachabilityFence(b);
137                 if (this != null) { this.ptrs_to.add(b); };
138                 return ret;
139         }
140
141         @Override public boolean equals(Object o) {
142                 if (!(o instanceof RevokeAndACK)) return false;
143                 return this.eq((RevokeAndACK)o);
144         }
145         /**
146          * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
147          */
148         public byte[] write() {
149                 byte[] ret = bindings.RevokeAndACK_write(this.ptr);
150                 Reference.reachabilityFence(this);
151                 return ret;
152         }
153
154         /**
155          * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
156          */
157         public static Result_RevokeAndACKDecodeErrorZ read(byte[] ser) {
158                 long ret = bindings.RevokeAndACK_read(ser);
159                 Reference.reachabilityFence(ser);
160                 if (ret >= 0 && ret <= 4096) { return null; }
161                 Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
162                 return ret_hu_conv;
163         }
164
165 }