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 or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Shutdown extends CommonBase {
16 Shutdown(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Shutdown_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.Shutdown_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
35 public void set_channel_id(byte[] val) {
36 bindings.Shutdown_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The destination of this peer's funds on closing.
43 * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
45 public byte[] get_scriptpubkey() {
46 byte[] ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
47 Reference.reachabilityFence(this);
52 * The destination of this peer's funds on closing.
53 * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
55 public void set_scriptpubkey(byte[] val) {
56 bindings.Shutdown_set_scriptpubkey(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Constructs a new Shutdown given each field
64 public static Shutdown of(byte[] channel_id_arg, byte[] scriptpubkey_arg) {
65 long ret = bindings.Shutdown_new(InternalUtils.check_arr_len(channel_id_arg, 32), scriptpubkey_arg);
66 Reference.reachabilityFence(channel_id_arg);
67 Reference.reachabilityFence(scriptpubkey_arg);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Shutdown(null, ret); }
70 ret_hu_conv.ptrs_to.add(ret_hu_conv);
75 long ret = bindings.Shutdown_clone_ptr(this.ptr);
76 Reference.reachabilityFence(this);
81 * Creates a copy of the Shutdown
83 public Shutdown clone() {
84 long ret = bindings.Shutdown_clone(this.ptr);
85 Reference.reachabilityFence(this);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Shutdown(null, ret); }
88 ret_hu_conv.ptrs_to.add(this);
93 * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
95 public byte[] write() {
96 byte[] ret = bindings.Shutdown_write(this.ptr);
97 Reference.reachabilityFence(this);
102 * Read a Shutdown from a byte array, created by Shutdown_write
104 public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
105 long ret = bindings.Shutdown_read(ser);
106 Reference.reachabilityFence(ser);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);