[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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 ChannelId 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                 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.CommitmentSigned_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          * A signature on the commitment transaction
44          */
45         public byte[] get_signature() {
46                 long ret = bindings.CommitmentSigned_get_signature(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          * A signature on the commitment transaction
55          */
56         public void set_signature(byte[] val) {
57                 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * Signatures on the HTLC transactions
64          * 
65          * Returns a copy of the field.
66          */
67         public byte[][] get_htlc_signatures() {
68                 long ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
69                 GC.KeepAlive(this);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
72                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
73                 for (int i = 0; i < ret_conv_8_len; i++) {
74                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
75                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
76                         ret_conv_8_arr[i] = ret_conv_8_conv;
77                 }
78                 bindings.free_buffer(ret);
79                 return ret_conv_8_arr;
80         }
81
82         /**
83          * Signatures on the HTLC transactions
84          */
85         public void set_htlc_signatures(byte[][] val) {
86                 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)))));
87                 GC.KeepAlive(this);
88                 GC.KeepAlive(val);
89         }
90
91         /**
92          * Constructs a new CommitmentSigned given each field
93          */
94         public static CommitmentSigned of(org.ldk.structs.ChannelId channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
95                 long ret = bindings.CommitmentSigned_new(channel_id_arg.ptr, 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)))));
96                 GC.KeepAlive(channel_id_arg);
97                 GC.KeepAlive(signature_arg);
98                 GC.KeepAlive(htlc_signatures_arg);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
101                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
103                 return ret_hu_conv;
104         }
105
106         internal long clone_ptr() {
107                 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
108                 GC.KeepAlive(this);
109                 return ret;
110         }
111
112         /**
113          * Creates a copy of the CommitmentSigned
114          */
115         public CommitmentSigned clone() {
116                 long ret = bindings.CommitmentSigned_clone(this.ptr);
117                 GC.KeepAlive(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
126          */
127         public long hash() {
128                 long ret = bindings.CommitmentSigned_hash(this.ptr);
129                 GC.KeepAlive(this);
130                 return ret;
131         }
132
133         public override int GetHashCode() {
134                 return (int)this.hash();
135         }
136         /**
137          * Checks if two CommitmentSigneds contain equal inner contents.
138          * This ignores pointers and is_owned flags and looks at the values in fields.
139          * Two objects with NULL inner values will be considered "equal" here.
140          */
141         public bool eq(org.ldk.structs.CommitmentSigned b) {
142                 bool ret = bindings.CommitmentSigned_eq(this.ptr, b.ptr);
143                 GC.KeepAlive(this);
144                 GC.KeepAlive(b);
145                 if (this != null) { this.ptrs_to.AddLast(b); };
146                 return ret;
147         }
148
149         public override bool Equals(object o) {
150                 if (!(o is CommitmentSigned)) return false;
151                 return this.eq((CommitmentSigned)o);
152         }
153         /**
154          * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
155          */
156         public byte[] write() {
157                 long ret = bindings.CommitmentSigned_write(this.ptr);
158                 GC.KeepAlive(this);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
161                 return ret_conv;
162         }
163
164         /**
165          * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
166          */
167         public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
168                 long ret = bindings.CommitmentSigned_read(InternalUtils.encodeUint8Array(ser));
169                 GC.KeepAlive(ser);
170                 if (ret >= 0 && ret <= 4096) { return null; }
171                 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
172                 return ret_hu_conv;
173         }
174
175 }
176 } } }