[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / FundingSigned.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 [`funding_signed`] message to be sent to or received from a peer.
13  * 
14  * Used in V1 channel establishment
15  * 
16  * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class FundingSigned extends CommonBase {
20         FundingSigned(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.FundingSigned_free(ptr); }
25         }
26
27         /**
28          * The channel ID
29          */
30         public ChannelId get_channel_id() {
31                 long ret = bindings.FundingSigned_get_channel_id(this.ptr);
32                 Reference.reachabilityFence(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
35                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36                 return ret_hu_conv;
37         }
38
39         /**
40          * The channel ID
41          */
42         public void set_channel_id(org.ldk.structs.ChannelId val) {
43                 bindings.FundingSigned_set_channel_id(this.ptr, val.ptr);
44                 Reference.reachabilityFence(this);
45                 Reference.reachabilityFence(val);
46                 if (this != null) { this.ptrs_to.add(val); };
47         }
48
49         /**
50          * The signature of the channel acceptor (fundee) on the initial commitment transaction
51          */
52         public byte[] get_signature() {
53                 byte[] ret = bindings.FundingSigned_get_signature(this.ptr);
54                 Reference.reachabilityFence(this);
55                 return ret;
56         }
57
58         /**
59          * The signature of the channel acceptor (fundee) on the initial commitment transaction
60          */
61         public void set_signature(byte[] val) {
62                 bindings.FundingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * Constructs a new FundingSigned given each field
69          */
70         public static FundingSigned of(org.ldk.structs.ChannelId channel_id_arg, byte[] signature_arg) {
71                 long ret = bindings.FundingSigned_new(channel_id_arg.ptr, InternalUtils.check_arr_len(signature_arg, 64));
72                 Reference.reachabilityFence(channel_id_arg);
73                 Reference.reachabilityFence(signature_arg);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
78                 return ret_hu_conv;
79         }
80
81         long clone_ptr() {
82                 long ret = bindings.FundingSigned_clone_ptr(this.ptr);
83                 Reference.reachabilityFence(this);
84                 return ret;
85         }
86
87         /**
88          * Creates a copy of the FundingSigned
89          */
90         public FundingSigned clone() {
91                 long ret = bindings.FundingSigned_clone(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Generates a non-cryptographic 64-bit hash of the FundingSigned.
101          */
102         public long hash() {
103                 long ret = bindings.FundingSigned_hash(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         @Override public int hashCode() {
109                 return (int)this.hash();
110         }
111         /**
112          * Checks if two FundingSigneds contain equal inner contents.
113          * This ignores pointers and is_owned flags and looks at the values in fields.
114          * Two objects with NULL inner values will be considered "equal" here.
115          */
116         public boolean eq(org.ldk.structs.FundingSigned b) {
117                 boolean ret = bindings.FundingSigned_eq(this.ptr, b.ptr);
118                 Reference.reachabilityFence(this);
119                 Reference.reachabilityFence(b);
120                 if (this != null) { this.ptrs_to.add(b); };
121                 return ret;
122         }
123
124         @Override public boolean equals(Object o) {
125                 if (!(o instanceof FundingSigned)) return false;
126                 return this.eq((FundingSigned)o);
127         }
128         /**
129          * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
130          */
131         public byte[] write() {
132                 byte[] ret = bindings.FundingSigned_write(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Read a FundingSigned from a byte array, created by FundingSigned_write
139          */
140         public static Result_FundingSignedDecodeErrorZ read(byte[] ser) {
141                 long ret = bindings.FundingSigned_read(ser);
142                 Reference.reachabilityFence(ser);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
145                 return ret_hu_conv;
146         }
147
148 }