[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Shutdown.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A [`shutdown`] message to be sent to or received from a peer.
11  * 
12  * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
13  */
14 public class Shutdown : CommonBase {
15         internal Shutdown(object _dummy, long ptr) : base(ptr) { }
16         ~Shutdown() {
17                 if (ptr != 0) { bindings.Shutdown_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.Shutdown_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
28                 return ret_conv;
29         }
30
31         /**
32          * The channel ID
33          */
34         public void set_channel_id(byte[] val) {
35                 bindings.Shutdown_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * The destination of this peer's funds on closing.
42          * 
43          * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
44          */
45         public byte[] get_scriptpubkey() {
46                 long ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
50                 return ret_conv;
51         }
52
53         /**
54          * The destination of this peer's funds on closing.
55          * 
56          * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
57          */
58         public void set_scriptpubkey(byte[] val) {
59                 bindings.Shutdown_set_scriptpubkey(this.ptr, InternalUtils.encodeUint8Array(val));
60                 GC.KeepAlive(this);
61                 GC.KeepAlive(val);
62         }
63
64         /**
65          * Constructs a new Shutdown given each field
66          */
67         public static Shutdown of(byte[] channel_id_arg, byte[] scriptpubkey_arg) {
68                 long ret = bindings.Shutdown_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeUint8Array(scriptpubkey_arg));
69                 GC.KeepAlive(channel_id_arg);
70                 GC.KeepAlive(scriptpubkey_arg);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Shutdown(null, ret); }
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
74                 return ret_hu_conv;
75         }
76
77         internal long clone_ptr() {
78                 long ret = bindings.Shutdown_clone_ptr(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * Creates a copy of the Shutdown
85          */
86         public Shutdown clone() {
87                 long ret = bindings.Shutdown_clone(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Shutdown(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Generates a non-cryptographic 64-bit hash of the Shutdown.
97          */
98         public long hash() {
99                 long ret = bindings.Shutdown_hash(this.ptr);
100                 GC.KeepAlive(this);
101                 return ret;
102         }
103
104         public override int GetHashCode() {
105                 return (int)this.hash();
106         }
107         /**
108          * Checks if two Shutdowns contain equal inner contents.
109          * This ignores pointers and is_owned flags and looks at the values in fields.
110          * Two objects with NULL inner values will be considered "equal" here.
111          */
112         public bool eq(org.ldk.structs.Shutdown b) {
113                 bool ret = bindings.Shutdown_eq(this.ptr, b == null ? 0 : b.ptr);
114                 GC.KeepAlive(this);
115                 GC.KeepAlive(b);
116                 if (this != null) { this.ptrs_to.AddLast(b); };
117                 return ret;
118         }
119
120         public override bool Equals(object o) {
121                 if (!(o is Shutdown)) return false;
122                 return this.eq((Shutdown)o);
123         }
124         /**
125          * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
126          */
127         public byte[] write() {
128                 long ret = bindings.Shutdown_write(this.ptr);
129                 GC.KeepAlive(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
132                 return ret_conv;
133         }
134
135         /**
136          * Read a Shutdown from a byte array, created by Shutdown_write
137          */
138         public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
139                 long ret = bindings.Shutdown_read(InternalUtils.encodeUint8Array(ser));
140                 GC.KeepAlive(ser);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
143                 return ret_hu_conv;
144         }
145
146 }
147 } } }