bb3d72fe9d98df488869067fa0ff79d289c92800
[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                 byte[] ret = bindings.CommitmentSigned_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * The channel ID
31          */
32         public void set_channel_id(byte[] val) {
33                 bindings.CommitmentSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * A signature on the commitment transaction
40          */
41         public byte[] get_signature() {
42                 byte[] ret = bindings.CommitmentSigned_get_signature(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * A signature on the commitment transaction
49          */
50         public void set_signature(byte[] val) {
51                 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * Signatures on the HTLC transactions
58          * 
59          * Returns a copy of the field.
60          */
61         public byte[][] get_htlc_signatures() {
62                 byte[][] ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
63                 GC.KeepAlive(this);
64                 return ret;
65         }
66
67         /**
68          * Signatures on the HTLC transactions
69          */
70         public void set_htlc_signatures(byte[][] val) {
71                 bindings.CommitmentSigned_set_htlc_signatures(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_8 => InternalUtils.check_arr_len(val_conv_8, 64)) : null);
72                 GC.KeepAlive(this);
73                 GC.KeepAlive(val);
74         }
75
76         /**
77          * Constructs a new CommitmentSigned given each field
78          */
79         public static CommitmentSigned of(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
80                 long ret = bindings.CommitmentSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(signature_arg, 64), htlc_signatures_arg != null ? InternalUtils.mapArray(htlc_signatures_arg, htlc_signatures_arg_conv_8 => InternalUtils.check_arr_len(htlc_signatures_arg_conv_8, 64)) : null);
81                 GC.KeepAlive(channel_id_arg);
82                 GC.KeepAlive(signature_arg);
83                 GC.KeepAlive(htlc_signatures_arg);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
87                 return ret_hu_conv;
88         }
89
90         internal long clone_ptr() {
91                 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
92                 GC.KeepAlive(this);
93                 return ret;
94         }
95
96         /**
97          * Creates a copy of the CommitmentSigned
98          */
99         public CommitmentSigned clone() {
100                 long ret = bindings.CommitmentSigned_clone(this.ptr);
101                 GC.KeepAlive(this);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Checks if two CommitmentSigneds contain equal inner contents.
110          * This ignores pointers and is_owned flags and looks at the values in fields.
111          * Two objects with NULL inner values will be considered "equal" here.
112          */
113         public bool eq(org.ldk.structs.CommitmentSigned b) {
114                 bool ret = bindings.CommitmentSigned_eq(this.ptr, b == null ? 0 : b.ptr);
115                 GC.KeepAlive(this);
116                 GC.KeepAlive(b);
117                 if (this != null) { this.ptrs_to.AddLast(b); };
118                 return ret;
119         }
120
121         public override bool Equals(object o) {
122                 if (!(o is CommitmentSigned)) return false;
123                 return this.eq((CommitmentSigned)o);
124         }
125         /**
126          * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
127          */
128         public byte[] write() {
129                 byte[] ret = bindings.CommitmentSigned_write(this.ptr);
130                 GC.KeepAlive(this);
131                 return ret;
132         }
133
134         /**
135          * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
136          */
137         public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
138                 long ret = bindings.CommitmentSigned_read(ser);
139                 GC.KeepAlive(ser);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
142                 return ret_hu_conv;
143         }
144
145 }
146 } } }