[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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 ChannelId 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                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The channel ID
34          */
35         public void set_channel_id(org.ldk.structs.ChannelId val) {
36                 bindings.Shutdown_set_channel_id(this.ptr, val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The destination of this peer's funds on closing.
44          * 
45          * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
46          */
47         public byte[] get_scriptpubkey() {
48                 long ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
49                 GC.KeepAlive(this);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
52                 return ret_conv;
53         }
54
55         /**
56          * The destination of this peer's funds on closing.
57          * 
58          * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
59          */
60         public void set_scriptpubkey(byte[] val) {
61                 bindings.Shutdown_set_scriptpubkey(this.ptr, InternalUtils.encodeUint8Array(val));
62                 GC.KeepAlive(this);
63                 GC.KeepAlive(val);
64         }
65
66         /**
67          * Constructs a new Shutdown given each field
68          */
69         public static Shutdown of(org.ldk.structs.ChannelId channel_id_arg, byte[] scriptpubkey_arg) {
70                 long ret = bindings.Shutdown_new(channel_id_arg.ptr, InternalUtils.encodeUint8Array(scriptpubkey_arg));
71                 GC.KeepAlive(channel_id_arg);
72                 GC.KeepAlive(scriptpubkey_arg);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Shutdown(null, ret); }
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
77                 return ret_hu_conv;
78         }
79
80         internal long clone_ptr() {
81                 long ret = bindings.Shutdown_clone_ptr(this.ptr);
82                 GC.KeepAlive(this);
83                 return ret;
84         }
85
86         /**
87          * Creates a copy of the Shutdown
88          */
89         public Shutdown clone() {
90                 long ret = bindings.Shutdown_clone(this.ptr);
91                 GC.KeepAlive(this);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Shutdown(null, ret); }
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Generates a non-cryptographic 64-bit hash of the Shutdown.
100          */
101         public long hash() {
102                 long ret = bindings.Shutdown_hash(this.ptr);
103                 GC.KeepAlive(this);
104                 return ret;
105         }
106
107         public override int GetHashCode() {
108                 return (int)this.hash();
109         }
110         /**
111          * Checks if two Shutdowns contain equal inner contents.
112          * This ignores pointers and is_owned flags and looks at the values in fields.
113          * Two objects with NULL inner values will be considered "equal" here.
114          */
115         public bool eq(org.ldk.structs.Shutdown b) {
116                 bool ret = bindings.Shutdown_eq(this.ptr, b.ptr);
117                 GC.KeepAlive(this);
118                 GC.KeepAlive(b);
119                 if (this != null) { this.ptrs_to.AddLast(b); };
120                 return ret;
121         }
122
123         public override bool Equals(object o) {
124                 if (!(o is Shutdown)) return false;
125                 return this.eq((Shutdown)o);
126         }
127         /**
128          * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
129          */
130         public byte[] write() {
131                 long ret = bindings.Shutdown_write(this.ptr);
132                 GC.KeepAlive(this);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
135                 return ret_conv;
136         }
137
138         /**
139          * Read a Shutdown from a byte array, created by Shutdown_write
140          */
141         public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
142                 long ret = bindings.Shutdown_read(InternalUtils.encodeUint8Array(ser));
143                 GC.KeepAlive(ser);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
146                 return ret_hu_conv;
147         }
148
149 }
150 } } }