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 [`shutdown`] message to be sent to or received from a peer.
14 * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
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 {
22 if (ptr != 0) { bindings.Shutdown_free(ptr); }
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); };
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); };
48 * The destination of this peer's funds on closing.
50 * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
52 public byte[] get_scriptpubkey() {
53 byte[] ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
54 Reference.reachabilityFence(this);
59 * The destination of this peer's funds on closing.
61 * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
63 public void set_scriptpubkey(byte[] val) {
64 bindings.Shutdown_set_scriptpubkey(this.ptr, val);
65 Reference.reachabilityFence(this);
66 Reference.reachabilityFence(val);
70 * Constructs a new Shutdown given each field
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); };
84 long ret = bindings.Shutdown_clone_ptr(this.ptr);
85 Reference.reachabilityFence(this);
90 * Creates a copy of the Shutdown
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); };
102 * Generates a non-cryptographic 64-bit hash of the Shutdown.
105 long ret = bindings.Shutdown_hash(this.ptr);
106 Reference.reachabilityFence(this);
110 @Override public int hashCode() {
111 return (int)this.hash();
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.
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); };
126 @Override public boolean equals(Object o) {
127 if (!(o instanceof Shutdown)) return false;
128 return this.eq((Shutdown)o);
131 * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
133 public byte[] write() {
134 byte[] ret = bindings.Shutdown_write(this.ptr);
135 Reference.reachabilityFence(this);
140 * Read a Shutdown from a byte array, created by Shutdown_write
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);