[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ClosingSigned.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 [`closing_signed`] message to be sent to or received from a peer.
11  * 
12  * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
13  */
14 public class ClosingSigned : CommonBase {
15         internal ClosingSigned(object _dummy, long ptr) : base(ptr) { }
16         ~ClosingSigned() {
17                 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.ClosingSigned_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.ClosingSigned_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 proposed total fee for the closing transaction
42          */
43         public long get_fee_satoshis() {
44                 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * The proposed total fee for the closing transaction
51          */
52         public void set_fee_satoshis(long val) {
53                 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * A signature on the closing transaction
60          */
61         public byte[] get_signature() {
62                 long ret = bindings.ClosingSigned_get_signature(this.ptr);
63                 GC.KeepAlive(this);
64                 if (ret >= 0 && ret <= 4096) { return null; }
65                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
66                 return ret_conv;
67         }
68
69         /**
70          * A signature on the closing transaction
71          */
72         public void set_signature(byte[] val) {
73                 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * The minimum and maximum fees which the sender is willing to accept, provided only by new
80          * nodes.
81          * 
82          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
83          */
84         public ClosingSignedFeeRange get_fee_range() {
85                 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
86                 GC.KeepAlive(this);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
90                 return ret_hu_conv;
91         }
92
93         /**
94          * The minimum and maximum fees which the sender is willing to accept, provided only by new
95          * nodes.
96          * 
97          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
98          */
99         public void set_fee_range(org.ldk.structs.ClosingSignedFeeRange val) {
100                 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(val);
103                 if (this != null) { this.ptrs_to.AddLast(val); };
104         }
105
106         /**
107          * Constructs a new ClosingSigned given each field
108          * 
109          * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
110          */
111         public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
112                 long ret = bindings.ClosingSigned_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), fee_satoshis_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), fee_range_arg == null ? 0 : fee_range_arg.ptr);
113                 GC.KeepAlive(channel_id_arg);
114                 GC.KeepAlive(fee_satoshis_arg);
115                 GC.KeepAlive(signature_arg);
116                 GC.KeepAlive(fee_range_arg);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_range_arg); };
121                 return ret_hu_conv;
122         }
123
124         internal long clone_ptr() {
125                 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
126                 GC.KeepAlive(this);
127                 return ret;
128         }
129
130         /**
131          * Creates a copy of the ClosingSigned
132          */
133         public ClosingSigned clone() {
134                 long ret = bindings.ClosingSigned_clone(this.ptr);
135                 GC.KeepAlive(this);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
138                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
139                 return ret_hu_conv;
140         }
141
142         /**
143          * Generates a non-cryptographic 64-bit hash of the ClosingSigned.
144          */
145         public long hash() {
146                 long ret = bindings.ClosingSigned_hash(this.ptr);
147                 GC.KeepAlive(this);
148                 return ret;
149         }
150
151         public override int GetHashCode() {
152                 return (int)this.hash();
153         }
154         /**
155          * Checks if two ClosingSigneds contain equal inner contents.
156          * This ignores pointers and is_owned flags and looks at the values in fields.
157          * Two objects with NULL inner values will be considered "equal" here.
158          */
159         public bool eq(org.ldk.structs.ClosingSigned b) {
160                 bool ret = bindings.ClosingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
161                 GC.KeepAlive(this);
162                 GC.KeepAlive(b);
163                 if (this != null) { this.ptrs_to.AddLast(b); };
164                 return ret;
165         }
166
167         public override bool Equals(object o) {
168                 if (!(o is ClosingSigned)) return false;
169                 return this.eq((ClosingSigned)o);
170         }
171         /**
172          * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
173          */
174         public byte[] write() {
175                 long ret = bindings.ClosingSigned_write(this.ptr);
176                 GC.KeepAlive(this);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
179                 return ret_conv;
180         }
181
182         /**
183          * Read a ClosingSigned from a byte array, created by ClosingSigned_write
184          */
185         public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
186                 long ret = bindings.ClosingSigned_read(InternalUtils.encodeUint8Array(ser));
187                 GC.KeepAlive(ser);
188                 if (ret >= 0 && ret <= 4096) { return null; }
189                 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
190                 return ret_hu_conv;
191         }
192
193 }
194 } } }