[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / Shutdown.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 [`shutdown`] message to be sent to or received from a peer.
13  * 
14  * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Shutdown extends CommonBase {
18         Shutdown(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.Shutdown_free(ptr); }
23         }
24
25         /**
26          * The channel ID
27          */
28         public ChannelId get_channel_id() {
29                 long ret = bindings.Shutdown_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.Shutdown_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 destination of this peer's funds on closing.
49          * 
50          * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
51          */
52         public byte[] get_scriptpubkey() {
53                 byte[] ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
54                 Reference.reachabilityFence(this);
55                 return ret;
56         }
57
58         /**
59          * The destination of this peer's funds on closing.
60          * 
61          * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
62          */
63         public void set_scriptpubkey(byte[] val) {
64                 bindings.Shutdown_set_scriptpubkey(this.ptr, val);
65                 Reference.reachabilityFence(this);
66                 Reference.reachabilityFence(val);
67         }
68
69         /**
70          * Constructs a new Shutdown given each field
71          */
72         public static Shutdown of(org.ldk.structs.ChannelId channel_id_arg, byte[] scriptpubkey_arg) {
73                 long ret = bindings.Shutdown_new(channel_id_arg.ptr, scriptpubkey_arg);
74                 Reference.reachabilityFence(channel_id_arg);
75                 Reference.reachabilityFence(scriptpubkey_arg);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 org.ldk.structs.Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Shutdown(null, ret); }
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
80                 return ret_hu_conv;
81         }
82
83         long clone_ptr() {
84                 long ret = bindings.Shutdown_clone_ptr(this.ptr);
85                 Reference.reachabilityFence(this);
86                 return ret;
87         }
88
89         /**
90          * Creates a copy of the Shutdown
91          */
92         public Shutdown clone() {
93                 long ret = bindings.Shutdown_clone(this.ptr);
94                 Reference.reachabilityFence(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Shutdown(null, ret); }
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Generates a non-cryptographic 64-bit hash of the Shutdown.
103          */
104         public long hash() {
105                 long ret = bindings.Shutdown_hash(this.ptr);
106                 Reference.reachabilityFence(this);
107                 return ret;
108         }
109
110         @Override public int hashCode() {
111                 return (int)this.hash();
112         }
113         /**
114          * Checks if two Shutdowns contain equal inner contents.
115          * This ignores pointers and is_owned flags and looks at the values in fields.
116          * Two objects with NULL inner values will be considered "equal" here.
117          */
118         public boolean eq(org.ldk.structs.Shutdown b) {
119                 boolean ret = bindings.Shutdown_eq(this.ptr, b.ptr);
120                 Reference.reachabilityFence(this);
121                 Reference.reachabilityFence(b);
122                 if (this != null) { this.ptrs_to.add(b); };
123                 return ret;
124         }
125
126         @Override public boolean equals(Object o) {
127                 if (!(o instanceof Shutdown)) return false;
128                 return this.eq((Shutdown)o);
129         }
130         /**
131          * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
132          */
133         public byte[] write() {
134                 byte[] ret = bindings.Shutdown_write(this.ptr);
135                 Reference.reachabilityFence(this);
136                 return ret;
137         }
138
139         /**
140          * Read a Shutdown from a byte array, created by Shutdown_write
141          */
142         public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
143                 long ret = bindings.Shutdown_read(ser);
144                 Reference.reachabilityFence(ser);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
147                 return ret_hu_conv;
148         }
149
150 }