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 [`commitment_signed`] message to be sent to or received from a peer.
14 * [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class CommitmentSigned extends CommonBase {
18 CommitmentSigned(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.CommitmentSigned_free(ptr); }
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.CommitmentSigned_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.CommitmentSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * A signature on the commitment transaction
46 public byte[] get_signature() {
47 byte[] ret = bindings.CommitmentSigned_get_signature(this.ptr);
48 Reference.reachabilityFence(this);
53 * A signature on the commitment transaction
55 public void set_signature(byte[] val) {
56 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Signatures on the HTLC transactions
64 * Returns a copy of the field.
66 public byte[][] get_htlc_signatures() {
67 byte[][] ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
68 Reference.reachabilityFence(this);
73 * Signatures on the HTLC transactions
75 public void set_htlc_signatures(byte[][] val) {
76 bindings.CommitmentSigned_set_htlc_signatures(this.ptr, val != null ? Arrays.stream(val).map(val_conv_8 -> InternalUtils.check_arr_len(val_conv_8, 64)).toArray(byte[][]::new) : null);
77 Reference.reachabilityFence(this);
78 Reference.reachabilityFence(val);
82 * Constructs a new CommitmentSigned given each field
84 public static CommitmentSigned of(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
85 long ret = bindings.CommitmentSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(signature_arg, 64), htlc_signatures_arg != null ? Arrays.stream(htlc_signatures_arg).map(htlc_signatures_arg_conv_8 -> InternalUtils.check_arr_len(htlc_signatures_arg_conv_8, 64)).toArray(byte[][]::new) : null);
86 Reference.reachabilityFence(channel_id_arg);
87 Reference.reachabilityFence(signature_arg);
88 Reference.reachabilityFence(htlc_signatures_arg);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
96 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
97 Reference.reachabilityFence(this);
102 * Creates a copy of the CommitmentSigned
104 public CommitmentSigned clone() {
105 long ret = bindings.CommitmentSigned_clone(this.ptr);
106 Reference.reachabilityFence(this);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
114 * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
117 long ret = bindings.CommitmentSigned_hash(this.ptr);
118 Reference.reachabilityFence(this);
122 @Override public int hashCode() {
123 return (int)this.hash();
126 * Checks if two CommitmentSigneds contain equal inner contents.
127 * This ignores pointers and is_owned flags and looks at the values in fields.
128 * Two objects with NULL inner values will be considered "equal" here.
130 public boolean eq(org.ldk.structs.CommitmentSigned b) {
131 boolean ret = bindings.CommitmentSigned_eq(this.ptr, b == null ? 0 : b.ptr);
132 Reference.reachabilityFence(this);
133 Reference.reachabilityFence(b);
134 if (this != null) { this.ptrs_to.add(b); };
138 @Override public boolean equals(Object o) {
139 if (!(o instanceof CommitmentSigned)) return false;
140 return this.eq((CommitmentSigned)o);
143 * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
145 public byte[] write() {
146 byte[] ret = bindings.CommitmentSigned_write(this.ptr);
147 Reference.reachabilityFence(this);
152 * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
154 public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
155 long ret = bindings.CommitmentSigned_read(ser);
156 Reference.reachabilityFence(ser);
157 if (ret >= 0 && ret <= 4096) { return null; }
158 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);