1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A revoke_and_ack message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RevokeAndACK extends CommonBase {
16 RevokeAndACK(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.RevokeAndACK_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.RevokeAndACK_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
35 public void set_channel_id(byte[] val) {
36 bindings.RevokeAndACK_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The secret corresponding to the per-commitment point
44 public byte[] get_per_commitment_secret() {
45 byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this.ptr);
46 Reference.reachabilityFence(this);
51 * The secret corresponding to the per-commitment point
53 public void set_per_commitment_secret(byte[] val) {
54 bindings.RevokeAndACK_set_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * The next sender-broadcast commitment transaction's per-commitment point
62 public byte[] get_next_per_commitment_point() {
63 byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this.ptr);
64 Reference.reachabilityFence(this);
69 * The next sender-broadcast commitment transaction's per-commitment point
71 public void set_next_per_commitment_point(byte[] val) {
72 bindings.RevokeAndACK_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
78 * Constructs a new RevokeAndACK given each field
80 public static RevokeAndACK of(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) {
81 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));
82 Reference.reachabilityFence(channel_id_arg);
83 Reference.reachabilityFence(per_commitment_secret_arg);
84 Reference.reachabilityFence(next_per_commitment_point_arg);
85 if (ret >= 0 && ret <= 4096) { return null; }
86 RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RevokeAndACK(null, ret); }
87 ret_hu_conv.ptrs_to.add(ret_hu_conv);
92 long ret = bindings.RevokeAndACK_clone_ptr(this.ptr);
93 Reference.reachabilityFence(this);
98 * Creates a copy of the RevokeAndACK
100 public RevokeAndACK clone() {
101 long ret = bindings.RevokeAndACK_clone(this.ptr);
102 Reference.reachabilityFence(this);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RevokeAndACK(null, ret); }
105 ret_hu_conv.ptrs_to.add(this);
110 * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
112 public byte[] write() {
113 byte[] ret = bindings.RevokeAndACK_write(this.ptr);
114 Reference.reachabilityFence(this);
119 * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
121 public static Result_RevokeAndACKDecodeErrorZ read(byte[] ser) {
122 long ret = bindings.RevokeAndACK_read(ser);
123 Reference.reachabilityFence(ser);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);