Update auto-generated bindings
[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 javax.annotation.Nullable;
8
9
10 /**
11  * A shutdown message to be sent or received from a peer
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Shutdown extends CommonBase {
15         Shutdown(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.Shutdown_free(ptr); }
20         }
21
22         /**
23          * The channel ID
24          */
25         public byte[] get_channel_id() {
26                 byte[] ret = bindings.Shutdown_get_channel_id(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * The channel ID
32          */
33         public void set_channel_id(byte[] val) {
34                 bindings.Shutdown_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
35         }
36
37         /**
38          * The destination of this peer's funds on closing.
39          * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
40          */
41         public byte[] get_scriptpubkey() {
42                 byte[] ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
43                 return ret;
44         }
45
46         /**
47          * The destination of this peer's funds on closing.
48          * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
49          */
50         public void set_scriptpubkey(byte[] val) {
51                 bindings.Shutdown_set_scriptpubkey(this.ptr, val);
52         }
53
54         /**
55          * Constructs a new Shutdown given each field
56          */
57         public static Shutdown of(byte[] channel_id_arg, byte[] scriptpubkey_arg) {
58                 long ret = bindings.Shutdown_new(InternalUtils.check_arr_len(channel_id_arg, 32), scriptpubkey_arg);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Shutdown(null, ret); }
61                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
62                 return ret_hu_conv;
63         }
64
65         long clone_ptr() {
66                 long ret = bindings.Shutdown_clone_ptr(this.ptr);
67                 return ret;
68         }
69
70         /**
71          * Creates a copy of the Shutdown
72          */
73         public Shutdown clone() {
74                 long ret = bindings.Shutdown_clone(this.ptr);
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Shutdown(null, ret); }
77                 ret_hu_conv.ptrs_to.add(this);
78                 return ret_hu_conv;
79         }
80
81         /**
82          * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
83          */
84         public byte[] write() {
85                 byte[] ret = bindings.Shutdown_write(this.ptr);
86                 return ret;
87         }
88
89         /**
90          * Read a Shutdown from a byte array, created by Shutdown_write
91          */
92         public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
93                 long ret = bindings.Shutdown_read(ser);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
96                 return ret_hu_conv;
97         }
98
99 }