[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / CommitmentSigned.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 [`commitment_signed`] message to be sent to or received from a peer.
13  * 
14  * [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.CommitmentSigned_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public ChannelId get_channel_id() {
29                 long ret = bindings.CommitmentSigned_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.CommitmentSigned_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          * A signature on the commitment transaction
49          */
50         public byte[] get_signature() {
51                 byte[] ret = bindings.CommitmentSigned_get_signature(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * A signature on the commitment transaction
58          */
59         public void set_signature(byte[] val) {
60                 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * Signatures on the HTLC transactions
67          * 
68          * Returns a copy of the field.
69          */
70         public byte[][] get_htlc_signatures() {
71                 byte[][] ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         /**
77          * Signatures on the HTLC transactions
78          */
79         public void set_htlc_signatures(byte[][] val) {
80                 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);
81                 Reference.reachabilityFence(this);
82                 Reference.reachabilityFence(val);
83         }
84
85         /**
86          * Constructs a new CommitmentSigned given each field
87          */
88         public static CommitmentSigned of(org.ldk.structs.ChannelId channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
89                 long ret = bindings.CommitmentSigned_new(channel_id_arg.ptr, 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);
90                 Reference.reachabilityFence(channel_id_arg);
91                 Reference.reachabilityFence(signature_arg);
92                 Reference.reachabilityFence(htlc_signatures_arg);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
97                 return ret_hu_conv;
98         }
99
100         long clone_ptr() {
101                 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * Creates a copy of the CommitmentSigned
108          */
109         public CommitmentSigned clone() {
110                 long ret = bindings.CommitmentSigned_clone(this.ptr);
111                 Reference.reachabilityFence(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
120          */
121         public long hash() {
122                 long ret = bindings.CommitmentSigned_hash(this.ptr);
123                 Reference.reachabilityFence(this);
124                 return ret;
125         }
126
127         @Override public int hashCode() {
128                 return (int)this.hash();
129         }
130         /**
131          * Checks if two CommitmentSigneds contain equal inner contents.
132          * This ignores pointers and is_owned flags and looks at the values in fields.
133          * Two objects with NULL inner values will be considered "equal" here.
134          */
135         public boolean eq(org.ldk.structs.CommitmentSigned b) {
136                 boolean ret = bindings.CommitmentSigned_eq(this.ptr, b.ptr);
137                 Reference.reachabilityFence(this);
138                 Reference.reachabilityFence(b);
139                 if (this != null) { this.ptrs_to.add(b); };
140                 return ret;
141         }
142
143         @Override public boolean equals(Object o) {
144                 if (!(o instanceof CommitmentSigned)) return false;
145                 return this.eq((CommitmentSigned)o);
146         }
147         /**
148          * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
149          */
150         public byte[] write() {
151                 byte[] ret = bindings.CommitmentSigned_write(this.ptr);
152                 Reference.reachabilityFence(this);
153                 return ret;
154         }
155
156         /**
157          * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
158          */
159         public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
160                 long ret = bindings.CommitmentSigned_read(ser);
161                 Reference.reachabilityFence(ser);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
164                 return ret_hu_conv;
165         }
166
167 }