]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/CommitmentSigned.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[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         }
40
41         /**
42          * A signature on the commitment transaction
43          */
44         public byte[] get_signature() {
45                 long ret = bindings.CommitmentSigned_get_signature(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
49                 return ret_conv;
50         }
51
52         /**
53          * A signature on the commitment transaction
54          */
55         public void set_signature(byte[] val) {
56                 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
57                 GC.KeepAlive(this);
58                 GC.KeepAlive(val);
59         }
60
61         /**
62          * Signatures on the HTLC transactions
63          * 
64          * Returns a copy of the field.
65          */
66         public byte[][] get_htlc_signatures() {
67                 long ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
68                 GC.KeepAlive(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
71                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
72                 for (int i = 0; i < ret_conv_8_len; i++) {
73                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
74                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
75                         ret_conv_8_arr[i] = ret_conv_8_conv;
76                 }
77                 bindings.free_buffer(ret);
78                 return ret_conv_8_arr;
79         }
80
81         /**
82          * Signatures on the HTLC transactions
83          */
84         public void set_htlc_signatures(byte[][] val) {
85                 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)))));
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(val);
88         }
89
90         /**
91          * Optional batch size and other parameters
92          * 
93          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
94          */
95         public CommitmentSignedBatch get_batch() {
96                 long ret = bindings.CommitmentSigned_get_batch(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.CommitmentSignedBatch ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSignedBatch(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Optional batch size and other parameters
106          * 
107          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
108          */
109         public void set_batch(org.ldk.structs.CommitmentSignedBatch val) {
110                 bindings.CommitmentSigned_set_batch(this.ptr, val == null ? 0 : val.ptr);
111                 GC.KeepAlive(this);
112                 GC.KeepAlive(val);
113         }
114
115         /**
116          * Constructs a new CommitmentSigned given each field
117          * 
118          * Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
119          */
120         public static CommitmentSigned of(org.ldk.structs.ChannelId channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg, org.ldk.structs.CommitmentSignedBatch batch_arg) {
121                 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)))), batch_arg == null ? 0 : batch_arg.ptr);
122                 GC.KeepAlive(channel_id_arg);
123                 GC.KeepAlive(signature_arg);
124                 GC.KeepAlive(htlc_signatures_arg);
125                 GC.KeepAlive(batch_arg);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
129                 return ret_hu_conv;
130         }
131
132         internal long clone_ptr() {
133                 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
134                 GC.KeepAlive(this);
135                 return ret;
136         }
137
138         /**
139          * Creates a copy of the CommitmentSigned
140          */
141         public CommitmentSigned clone() {
142                 long ret = bindings.CommitmentSigned_clone(this.ptr);
143                 GC.KeepAlive(this);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
146                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
147                 return ret_hu_conv;
148         }
149
150         /**
151          * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
152          */
153         public long hash() {
154                 long ret = bindings.CommitmentSigned_hash(this.ptr);
155                 GC.KeepAlive(this);
156                 return ret;
157         }
158
159         public override int GetHashCode() {
160                 return (int)this.hash();
161         }
162         /**
163          * Checks if two CommitmentSigneds contain equal inner contents.
164          * This ignores pointers and is_owned flags and looks at the values in fields.
165          * Two objects with NULL inner values will be considered "equal" here.
166          */
167         public bool eq(org.ldk.structs.CommitmentSigned b) {
168                 bool ret = bindings.CommitmentSigned_eq(this.ptr, b.ptr);
169                 GC.KeepAlive(this);
170                 GC.KeepAlive(b);
171                 if (this != null) { this.ptrs_to.AddLast(b); };
172                 return ret;
173         }
174
175         public override bool Equals(object o) {
176                 if (!(o is CommitmentSigned)) return false;
177                 return this.eq((CommitmentSigned)o);
178         }
179         /**
180          * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
181          */
182         public byte[] write() {
183                 long ret = bindings.CommitmentSigned_write(this.ptr);
184                 GC.KeepAlive(this);
185                 if (ret >= 0 && ret <= 4096) { return null; }
186                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
187                 return ret_conv;
188         }
189
190         /**
191          * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
192          */
193         public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
194                 long ret = bindings.CommitmentSigned_read(InternalUtils.encodeUint8Array(ser));
195                 GC.KeepAlive(ser);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
198                 return ret_hu_conv;
199         }
200
201 }
202 } } }