[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / CommitmentSigned.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 [`commitment_signed`] message to be sent to or received from a peer.
11  * 
12  * [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
13  */
14 public class CommitmentSigned : CommonBase {
15         internal CommitmentSigned(object _dummy, long ptr) : base(ptr) { }
16         ~CommitmentSigned() {
17                 if (ptr != 0) { bindings.CommitmentSigned_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.CommitmentSigned_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.CommitmentSigned_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          * A signature on the commitment transaction
42          */
43         public byte[] get_signature() {
44                 long ret = bindings.CommitmentSigned_get_signature(this.ptr);
45                 GC.KeepAlive(this);
46                 if (ret >= 0 && ret <= 4096) { return null; }
47                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
48                 return ret_conv;
49         }
50
51         /**
52          * A signature on the commitment transaction
53          */
54         public void set_signature(byte[] val) {
55                 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * Signatures on the HTLC transactions
62          * 
63          * Returns a copy of the field.
64          */
65         public byte[][] get_htlc_signatures() {
66                 long ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
67                 GC.KeepAlive(this);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
70                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
71                 for (int i = 0; i < ret_conv_8_len; i++) {
72                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
73                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
74                         ret_conv_8_arr[i] = ret_conv_8_conv;
75                 }
76                 bindings.free_buffer(ret);
77                 return ret_conv_8_arr;
78         }
79
80         /**
81          * Signatures on the HTLC transactions
82          */
83         public void set_htlc_signatures(byte[][] val) {
84                 bindings.CommitmentSigned_set_htlc_signatures(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val_conv_8, 64)))));
85                 GC.KeepAlive(this);
86                 GC.KeepAlive(val);
87         }
88
89         /**
90          * Constructs a new CommitmentSigned given each field
91          */
92         public static CommitmentSigned of(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
93                 long ret = bindings.CommitmentSigned_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(htlc_signatures_arg, htlc_signatures_arg_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_signatures_arg_conv_8, 64)))));
94                 GC.KeepAlive(channel_id_arg);
95                 GC.KeepAlive(signature_arg);
96                 GC.KeepAlive(htlc_signatures_arg);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
99                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
100                 return ret_hu_conv;
101         }
102
103         internal long clone_ptr() {
104                 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
105                 GC.KeepAlive(this);
106                 return ret;
107         }
108
109         /**
110          * Creates a copy of the CommitmentSigned
111          */
112         public CommitmentSigned clone() {
113                 long ret = bindings.CommitmentSigned_clone(this.ptr);
114                 GC.KeepAlive(this);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Checks if two CommitmentSigneds contain equal inner contents.
123          * This ignores pointers and is_owned flags and looks at the values in fields.
124          * Two objects with NULL inner values will be considered "equal" here.
125          */
126         public bool eq(org.ldk.structs.CommitmentSigned b) {
127                 bool ret = bindings.CommitmentSigned_eq(this.ptr, b == null ? 0 : b.ptr);
128                 GC.KeepAlive(this);
129                 GC.KeepAlive(b);
130                 if (this != null) { this.ptrs_to.AddLast(b); };
131                 return ret;
132         }
133
134         public override bool Equals(object o) {
135                 if (!(o is CommitmentSigned)) return false;
136                 return this.eq((CommitmentSigned)o);
137         }
138         /**
139          * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
140          */
141         public byte[] write() {
142                 long ret = bindings.CommitmentSigned_write(this.ptr);
143                 GC.KeepAlive(this);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
146                 return ret_conv;
147         }
148
149         /**
150          * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
151          */
152         public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
153                 long ret = bindings.CommitmentSigned_read(InternalUtils.encodeUint8Array(ser));
154                 GC.KeepAlive(ser);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
157                 return ret_hu_conv;
158         }
159
160 }
161 } } }