[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / ClosingSigned.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 [`closing_signed`] message to be sent to or received from a peer.
13  * 
14  * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ClosingSigned extends CommonBase {
18         ClosingSigned(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public ChannelId get_channel_id() {
29                 long ret = bindings.ClosingSigned_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.ClosingSigned_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 proposed total fee for the closing transaction
49          */
50         public long get_fee_satoshis() {
51                 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * The proposed total fee for the closing transaction
58          */
59         public void set_fee_satoshis(long val) {
60                 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * A signature on the closing transaction
67          */
68         public byte[] get_signature() {
69                 byte[] ret = bindings.ClosingSigned_get_signature(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * A signature on the closing transaction
76          */
77         public void set_signature(byte[] val) {
78                 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(val);
81         }
82
83         /**
84          * The minimum and maximum fees which the sender is willing to accept, provided only by new
85          * nodes.
86          * 
87          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
88          */
89         @Nullable
90         public ClosingSignedFeeRange get_fee_range() {
91                 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * The minimum and maximum fees which the sender is willing to accept, provided only by new
101          * nodes.
102          * 
103          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
104          */
105         public void set_fee_range(@Nullable org.ldk.structs.ClosingSignedFeeRange val) {
106                 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr);
107                 Reference.reachabilityFence(this);
108                 Reference.reachabilityFence(val);
109                 if (this != null) { this.ptrs_to.add(val); };
110         }
111
112         /**
113          * Constructs a new ClosingSigned given each field
114          * 
115          * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
116          */
117         public static ClosingSigned of(org.ldk.structs.ChannelId channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, @Nullable org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
118                 long ret = bindings.ClosingSigned_new(channel_id_arg.ptr, fee_satoshis_arg, InternalUtils.check_arr_len(signature_arg, 64), fee_range_arg == null ? 0 : fee_range_arg.ptr);
119                 Reference.reachabilityFence(channel_id_arg);
120                 Reference.reachabilityFence(fee_satoshis_arg);
121                 Reference.reachabilityFence(signature_arg);
122                 Reference.reachabilityFence(fee_range_arg);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_range_arg); };
128                 return ret_hu_conv;
129         }
130
131         long clone_ptr() {
132                 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Creates a copy of the ClosingSigned
139          */
140         public ClosingSigned clone() {
141                 long ret = bindings.ClosingSigned_clone(this.ptr);
142                 Reference.reachabilityFence(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Generates a non-cryptographic 64-bit hash of the ClosingSigned.
151          */
152         public long hash() {
153                 long ret = bindings.ClosingSigned_hash(this.ptr);
154                 Reference.reachabilityFence(this);
155                 return ret;
156         }
157
158         @Override public int hashCode() {
159                 return (int)this.hash();
160         }
161         /**
162          * Checks if two ClosingSigneds contain equal inner contents.
163          * This ignores pointers and is_owned flags and looks at the values in fields.
164          * Two objects with NULL inner values will be considered "equal" here.
165          */
166         public boolean eq(org.ldk.structs.ClosingSigned b) {
167                 boolean ret = bindings.ClosingSigned_eq(this.ptr, b.ptr);
168                 Reference.reachabilityFence(this);
169                 Reference.reachabilityFence(b);
170                 if (this != null) { this.ptrs_to.add(b); };
171                 return ret;
172         }
173
174         @Override public boolean equals(Object o) {
175                 if (!(o instanceof ClosingSigned)) return false;
176                 return this.eq((ClosingSigned)o);
177         }
178         /**
179          * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
180          */
181         public byte[] write() {
182                 byte[] ret = bindings.ClosingSigned_write(this.ptr);
183                 Reference.reachabilityFence(this);
184                 return ret;
185         }
186
187         /**
188          * Read a ClosingSigned from a byte array, created by ClosingSigned_write
189          */
190         public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
191                 long ret = bindings.ClosingSigned_read(ser);
192                 Reference.reachabilityFence(ser);
193                 if (ret >= 0 && ret <= 4096) { return null; }
194                 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
195                 return ret_hu_conv;
196         }
197
198 }