[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / RevokeAndACK.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 [`revoke_and_ack`] message to be sent to or received from a peer.
11  * 
12  * [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
13  */
14 public class RevokeAndACK : CommonBase {
15         internal RevokeAndACK(object _dummy, long ptr) : base(ptr) { }
16         ~RevokeAndACK() {
17                 if (ptr != 0) { bindings.RevokeAndACK_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.RevokeAndACK_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.RevokeAndACK_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          * The secret corresponding to the per-commitment point
42          */
43         public byte[] get_per_commitment_secret() {
44                 long ret = bindings.RevokeAndACK_get_per_commitment_secret(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          * The secret corresponding to the per-commitment point
53          */
54         public void set_per_commitment_secret(byte[] val) {
55                 bindings.RevokeAndACK_set_per_commitment_secret(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The next sender-broadcast commitment transaction's per-commitment point
62          */
63         public byte[] get_next_per_commitment_point() {
64                 long ret = bindings.RevokeAndACK_get_next_per_commitment_point(this.ptr);
65                 GC.KeepAlive(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
68                 return ret_conv;
69         }
70
71         /**
72          * The next sender-broadcast commitment transaction's per-commitment point
73          */
74         public void set_next_per_commitment_point(byte[] val) {
75                 bindings.RevokeAndACK_set_next_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * Constructs a new RevokeAndACK given each field
82          */
83         public static RevokeAndACK of(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) {
84                 long ret = bindings.RevokeAndACK_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_secret_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(next_per_commitment_point_arg, 33)));
85                 GC.KeepAlive(channel_id_arg);
86                 GC.KeepAlive(per_commitment_secret_arg);
87                 GC.KeepAlive(next_per_commitment_point_arg);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
91                 return ret_hu_conv;
92         }
93
94         internal long clone_ptr() {
95                 long ret = bindings.RevokeAndACK_clone_ptr(this.ptr);
96                 GC.KeepAlive(this);
97                 return ret;
98         }
99
100         /**
101          * Creates a copy of the RevokeAndACK
102          */
103         public RevokeAndACK clone() {
104                 long ret = bindings.RevokeAndACK_clone(this.ptr);
105                 GC.KeepAlive(this);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109                 return ret_hu_conv;
110         }
111
112         /**
113          * Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
114          */
115         public long hash() {
116                 long ret = bindings.RevokeAndACK_hash(this.ptr);
117                 GC.KeepAlive(this);
118                 return ret;
119         }
120
121         public override int GetHashCode() {
122                 return (int)this.hash();
123         }
124         /**
125          * Checks if two RevokeAndACKs contain equal inner contents.
126          * This ignores pointers and is_owned flags and looks at the values in fields.
127          * Two objects with NULL inner values will be considered "equal" here.
128          */
129         public bool eq(org.ldk.structs.RevokeAndACK b) {
130                 bool ret = bindings.RevokeAndACK_eq(this.ptr, b == null ? 0 : b.ptr);
131                 GC.KeepAlive(this);
132                 GC.KeepAlive(b);
133                 if (this != null) { this.ptrs_to.AddLast(b); };
134                 return ret;
135         }
136
137         public override bool Equals(object o) {
138                 if (!(o is RevokeAndACK)) return false;
139                 return this.eq((RevokeAndACK)o);
140         }
141         /**
142          * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
143          */
144         public byte[] write() {
145                 long ret = bindings.RevokeAndACK_write(this.ptr);
146                 GC.KeepAlive(this);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
149                 return ret_conv;
150         }
151
152         /**
153          * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
154          */
155         public static Result_RevokeAndACKDecodeErrorZ read(byte[] ser) {
156                 long ret = bindings.RevokeAndACK_read(InternalUtils.encodeUint8Array(ser));
157                 GC.KeepAlive(ser);
158                 if (ret >= 0 && ret <= 4096) { return null; }
159                 Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
160                 return ret_hu_conv;
161         }
162
163 }
164 } } }