Update auto-updated Java files
[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 or received from a peer
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Shutdown_free(ptr); }
21         }
22
23         /**
24          * The channel ID
25          */
26         public byte[] get_channel_id() {
27                 byte[] ret = bindings.Shutdown_get_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The channel ID
34          */
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);
39         }
40
41         /**
42          * The destination of this peer's funds on closing.
43          * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
44          */
45         public byte[] get_scriptpubkey() {
46                 byte[] ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * The destination of this peer's funds on closing.
53          * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
54          */
55         public void set_scriptpubkey(byte[] val) {
56                 bindings.Shutdown_set_scriptpubkey(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * Constructs a new Shutdown given each field
63          */
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);
71                 return ret_hu_conv;
72         }
73
74         long clone_ptr() {
75                 long ret = bindings.Shutdown_clone_ptr(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the Shutdown
82          */
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);
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
94          */
95         public byte[] write() {
96                 byte[] ret = bindings.Shutdown_write(this.ptr);
97                 Reference.reachabilityFence(this);
98                 return ret;
99         }
100
101         /**
102          * Read a Shutdown from a byte array, created by Shutdown_write
103          */
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);
109                 return ret_hu_conv;
110         }
111
112 }