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