6 namespace org { namespace ldk { namespace structs {
10 * A [`shutdown`] message to be sent to or received from a peer.
12 * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
14 public class Shutdown : CommonBase {
15 internal Shutdown(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.Shutdown_free(ptr); }
23 public byte[] get_channel_id() {
24 long ret = bindings.Shutdown_get_channel_id(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
34 public void set_channel_id(byte[] val) {
35 bindings.Shutdown_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
41 * The destination of this peer's funds on closing.
43 * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
45 public byte[] get_scriptpubkey() {
46 long ret = bindings.Shutdown_get_scriptpubkey(this.ptr);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
54 * The destination of this peer's funds on closing.
56 * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
58 public void set_scriptpubkey(byte[] val) {
59 bindings.Shutdown_set_scriptpubkey(this.ptr, InternalUtils.encodeUint8Array(val));
65 * Constructs a new Shutdown given each field
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); };
77 internal long clone_ptr() {
78 long ret = bindings.Shutdown_clone_ptr(this.ptr);
84 * Creates a copy of the Shutdown
86 public Shutdown clone() {
87 long ret = bindings.Shutdown_clone(this.ptr);
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); };
96 * Checks if two Shutdowns contain equal inner contents.
97 * This ignores pointers and is_owned flags and looks at the values in fields.
98 * Two objects with NULL inner values will be considered "equal" here.
100 public bool eq(org.ldk.structs.Shutdown b) {
101 bool ret = bindings.Shutdown_eq(this.ptr, b == null ? 0 : b.ptr);
104 if (this != null) { this.ptrs_to.AddLast(b); };
108 public override bool Equals(object o) {
109 if (!(o is Shutdown)) return false;
110 return this.eq((Shutdown)o);
113 * Serialize the Shutdown object into a byte array which can be read by Shutdown_read
115 public byte[] write() {
116 long ret = bindings.Shutdown_write(this.ptr);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
124 * Read a Shutdown from a byte array, created by Shutdown_write
126 public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
127 long ret = bindings.Shutdown_read(InternalUtils.encodeUint8Array(ser));
129 if (ret >= 0 && ret <= 4096) { return null; }
130 Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);