8546838a04dc29362add1c8c0249684e013260e7
[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 or received from a peer
11  */
12 public class RevokeAndACK : CommonBase {
13         internal RevokeAndACK(object _dummy, long ptr) : base(ptr) { }
14         ~RevokeAndACK() {
15                 if (ptr != 0) { bindings.RevokeAndACK_free(ptr); }
16         }
17
18         /**
19          * The channel ID
20          */
21         public byte[] get_channel_id() {
22                 byte[] ret = bindings.RevokeAndACK_get_channel_id(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * The channel ID
29          */
30         public void set_channel_id(byte[] val) {
31                 bindings.RevokeAndACK_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * The secret corresponding to the per-commitment point
38          */
39         public byte[] get_per_commitment_secret() {
40                 byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this.ptr);
41                 GC.KeepAlive(this);
42                 return ret;
43         }
44
45         /**
46          * The secret corresponding to the per-commitment point
47          */
48         public void set_per_commitment_secret(byte[] val) {
49                 bindings.RevokeAndACK_set_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
50                 GC.KeepAlive(this);
51                 GC.KeepAlive(val);
52         }
53
54         /**
55          * The next sender-broadcast commitment transaction's per-commitment point
56          */
57         public byte[] get_next_per_commitment_point() {
58                 byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this.ptr);
59                 GC.KeepAlive(this);
60                 return ret;
61         }
62
63         /**
64          * The next sender-broadcast commitment transaction's per-commitment point
65          */
66         public void set_next_per_commitment_point(byte[] val) {
67                 bindings.RevokeAndACK_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
68                 GC.KeepAlive(this);
69                 GC.KeepAlive(val);
70         }
71
72         /**
73          * Constructs a new RevokeAndACK given each field
74          */
75         public static RevokeAndACK of(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) {
76                 long ret = bindings.RevokeAndACK_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(per_commitment_secret_arg, 32), InternalUtils.check_arr_len(next_per_commitment_point_arg, 33));
77                 GC.KeepAlive(channel_id_arg);
78                 GC.KeepAlive(per_commitment_secret_arg);
79                 GC.KeepAlive(next_per_commitment_point_arg);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
83                 return ret_hu_conv;
84         }
85
86         internal long clone_ptr() {
87                 long ret = bindings.RevokeAndACK_clone_ptr(this.ptr);
88                 GC.KeepAlive(this);
89                 return ret;
90         }
91
92         /**
93          * Creates a copy of the RevokeAndACK
94          */
95         public RevokeAndACK clone() {
96                 long ret = bindings.RevokeAndACK_clone(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevokeAndACK(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Checks if two RevokeAndACKs contain equal inner contents.
106          * This ignores pointers and is_owned flags and looks at the values in fields.
107          * Two objects with NULL inner values will be considered "equal" here.
108          */
109         public bool eq(org.ldk.structs.RevokeAndACK b) {
110                 bool ret = bindings.RevokeAndACK_eq(this.ptr, b == null ? 0 : b.ptr);
111                 GC.KeepAlive(this);
112                 GC.KeepAlive(b);
113                 if (this != null) { this.ptrs_to.AddLast(b); };
114                 return ret;
115         }
116
117         public override bool Equals(object o) {
118                 if (!(o is RevokeAndACK)) return false;
119                 return this.eq((RevokeAndACK)o);
120         }
121         /**
122          * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
123          */
124         public byte[] write() {
125                 byte[] ret = bindings.RevokeAndACK_write(this.ptr);
126                 GC.KeepAlive(this);
127                 return ret;
128         }
129
130         /**
131          * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
132          */
133         public static Result_RevokeAndACKDecodeErrorZ read(byte[] ser) {
134                 long ret = bindings.RevokeAndACK_read(ser);
135                 GC.KeepAlive(ser);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
138                 return ret_hu_conv;
139         }
140
141 }
142 } } }